关于Mybatis逆向工程的一些查询操作

查询所有数据不带参数的可以使用:
selectByExampleWithBLOBs(example)

查询的数据需要按字段的排序的:

example.setOrderByClause("字段名 ASC"); //升序排列,desc为降序排列。

去除重复的数据:

example.setDistinct(false)//去除重复,boolean型,true为选择不重复的记录。
按条件查询(例子):
                UserExample userExample = new UserExample();
		
		UserExample.Criteria criteria = userExample.createCriteria();
		
		criteria.andUsernameEqualTo(username);
		
		List<User> user = userMapper.selectByExample(userExample);
如果需要联表查询,逆向工程是不能够满足的(进行多次查询也可以,但是会影响性能),所以要在Mapper以及其配置文件进行更改。


猜你喜欢

转载自blog.csdn.net/java_hzp/article/details/80549256