天天看点

简单使用mybatis中example实体类查询

使用插件genertor自动生成实体类是会一起生成一个example实体类,一直不知道如何使用,这里是两个简单的使用

1.单一条件查询(例如:通过id查询,可更换为其他条件,如username等):

CrmPostExample example = new CrmPostExample();
CrmPostExample.Criteria criteria = example.createCriteria();
criteria.andDepidEqualTo(depId);
List<CrmPost> crmPosts = crmPostMapper.selectByExample(example);
           

2. 不添加条件即为查询所有

CrmPostExample example = new CrmPostExample();
List<CrmPost> crmPosts = crmPostMapper.selectByExample(example);
           

暂时只知道这么两种简单用法,知道后再更新

继续阅读