Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
1254042329
@1254042329
Who knows this question?
锐哥
@itflash
weekendsqls 怎么使用or? builder.orwhere不起作用
@abel533
锐哥
@itflash
没有大佬在吗
锐哥
@itflash
没看到or的用法
daibinNJ
@daibinNJ
domainObjectRenamingRule 这个domainName 不是驼峰的怎么办
@abel533 domainObjectRenamingRule 这个domainName 不是驼峰的怎么办
@abel533 还想问问,表的实例,主键没有自动生成@Id 注解是怎么回事,@Table @Column(name = "id") 这个都是有的
Liuzh
@abel533
@daibinNJ @Id 注解只能看代码找原因,一般建议建个基类配置好主键策略和相关注解,<table> 中配置 rootClass 继承。
大水牛
@it-noob
@abel533 大佬您好,我想请教下,

动态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();
我看builder模式里的条件和主动创建的条件,不是同一个对象,貌似不生效。
Akhilesh Tyagi
@tyagiakhilesh

Hello, I use mybatis3 with postgres; I am running this query:

Preparing: SELECT * FROM some_table ORDER BY ? ASC LIMIT ? OFFSET ?

but ASC / DESC are not being honored

is this a known bug or something ?
Liuzh
@abel533
@tyagiakhilesh Replace with order by ${orderByColumn} ASC.
Akhilesh Tyagi
@tyagiakhilesh
@abel533 thank you for responding. I did figured that after posting here. But thanks anyway. :-)
Akhilesh Tyagi
@tyagiakhilesh

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?

shannon312
@shannon312
@shannon312
@abel533 这个分页插件代码实现有点欠妥,com.github.pagehelper.PageInterceptor#intercept,这个实现方法里最后并没有调用org.apache.ibatis.plugin.Invocation#proceed这个方法,导致这个插件不能和其他插件共用,也就是不能和其他插件一起组合成InterceptorChain ,这个插件有排他性,使用了你这个分页插件,如果你这个分页插件不是第一个,会导致在你这个分页插件之前的所有插件都不会被调用了
不知道大家有没有发现这个问题
shannon312
@shannon312
soga 了解啦
BALAJI1183
@BALAJI1183
Hi All
Any pointers on bulk insert or bulk update
using MyBatis and using session template
Liuzh
@abel533
@BALAJI1183 batch?
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
BALAJI1183
@BALAJI1183
Hi but I don’t want to manage transaction within this. Is there a way transaction can be handled outside pretty much like JDBCtemplate, hibernatetemplate etc
Seayon
@Seayon
image.png
image.png
image.png
image.png
打扰了,请教一下,我创建了一个自定义的拦截器,想问下为何我的拦截器会被调用两次,顺序是 我的拦截器-》pagehelper 的拦截器-》又回到我的拦截器
导致我拼接处理 sql 会被处理两次。。。虽说问题也不大能用,但还是想知道为何,烦请大佬有时间指点下,先谢过!
Seayon
@Seayon
首先非常感谢作者百忙之中的回复!您的这篇文章我在使用之前看过好几遍啦!昨天晚上想了半天最后发现是自己对于 spring 的机制不熟悉,导致自己配置的拦截器在 spring 里面注册了两次(在类上使用@Component 的同时又配置了一个@Bean ),mybatis 也添加了两次,所以会进入两次,现在已经解决了,非常感谢
PengLiang
@pengliang56
大家好
请教下,现在支持接受optional返回吗?或者说复杂类型的返回值,比如(optional<List<Collection>>),的参数
PengLiang
@pengliang56
因为我在<mybatis-spring-boot-starter>2.1.0 版本中接受optional<List<Collection>>失败,我想了解是我接受的方式不对,还是暂时不支持
Wenxing Zheng
@wenxzhen
dear all,
regarding the performance of mybatis, is there any stats metric?
What I wanna know it's the cost of mybatis
Anyzm
@Anyzm
为啥加了@Transient注解,字段还是被mybatis持久化了
有没有大神指导一下
Yue Yan
@yanxingzhi
Hi, I don't understand the reason why use factory parttern to product a SqlSessionFactory. The SqlSessionFactoryBean is a singleton in fact. why not use a bean intead of a factory bean. thanks.
Liuzh
@abel533
@Anyzm 你用的通用Mapper?只有特殊框架认注解,纯MyBatis不认。
胡洋
@huyang19881115
pagehelper 分页都不走
咋办啊?
PageInfo<Map<String, String>> page =PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(()->taskMapper.getPlanData(planDataRequest));

pagehelper.helperDialect=mysql
pagehelper.reasonable=true

这个配置有问题,会导致所有参数里面有pageSize pageNum 都嵌套分页

pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql

连count 的语句也不输出了
Liuzh
@abel533
@huyang19881115 嵌套分页时什么?可以通过配置关闭自动分页。可以修改pageSize默认识别的名字。