mybatis-genetor反向生成的example.setDistinct(true)去重无效

  那些说什么改mapper里面的SQL语句什么的,改了那还能叫mybatis-genetor吗?

言归正传,遇到问题第一步,看源码;随便打开一个mapper,搜索Distinct,答案便出来了。
在这里插入图片描述

  不要用selectByExample,改用selectByExampleSelective,在里面写上你要去重的字段,例如要对名字去重:

example.setDistinct(true);
goodsMapper.selectByExampleSelective(example, Goods.Column.name);

猜你喜欢

转载自blog.csdn.net/weixin_43899542/article/details/108362275