id
") 这个都是有的
动态SQL的Example.Criteria是自动创建的
Example example = new Example(Country.class);
Example.Criteria criteria = example.createCriteria();
if(query.getCountryname() != null){
criteria.andLike("countryname", query.getCountryname() + "%");
}
if(query.getId() != null){
criteria.andGreaterThan("id", query.getId());
}
List<Country> countries = mapper.selectByExample(example);
不可以用下面这种方式创建的example来动态设置条件吧
Example example = Example.builder(Country.class)
.select("countryname")
.where(Sqls.custom().andGreaterThan("id", 100))
.orderByAsc("countrycode")
.forUpdate()
.build();
Hey Guys,
I have stumbled upon something and wanted your advice.
I have a DAO class where I use mybatis3, something like this:
function1() :
try (SqlSession session = sqlSessionFactory.openSession(true)) {
//select
//update
session.commit();
}
function2():
try (SqlSession session = sqlSessionFactory.openSession(true)) {
//update
session.commit();
}
function3():
try (SqlSession session = sqlSessionFactory.openSession(true)) {
//insert
session.commit();
}
I am facing some deadlocks in postgres with this code under heavy load. Now I wrote some integration tests, and I was able to reproduce the deadlock fairly consistently. I do not really see why the deadlock should happen. I did note though in my code, I am opening session with autocommit true, so I figured I do not need to do an explicit commit. I made that adjustment and removed the session.commit(); lines from each of these functions. And now using the same test case, I am not able to see deadlock problem.
I tried several times and results are pretty consistent: With explicit commit, I do see deadlock issue in postgres. Without explicit commit, I don't see deadlock.
Question: Was/Is deadlock side effect of me doing autocommit session and simultaneously doing an explicit commit ? Can anyone explain this behavior to me?
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql