mybatis自动生成带的Example用法

自动生成工具地址
https://github.com/gyn781369549/mybatis-generator-gui-master.git

例子

UsersExample example = new UsersExample();
UsersExample.Criteria criteria = example.createCriteria();
//查询条件
criteria.andOpenidEqualTo(openid);
查询该openid的用户 
example.setLimit(10);//条数
example.setOffset(1);//越过1数据  从第二条开始 取10条数据
List us = usersMapper.selectByExample(example);


各种方法

	//sql 排序字段名  规则
	example.setOrderByClause("id ASC");

	是null
		IsNull
		
	不是null
		IsNotNull
		
	等于
		EqualTo
		
	不等于
		NotEqualTo
		
	大于
		GreaterThan
		
	大于等于
		GreaterThanOrEqualTo
		
	小于
		LessThan
		
	小于等于
		LessThanOrEqualTo
		
	like
		Like
		
	no like
		NotLike
		
	in 
		In
		
	not in
		NotIn
		
	between BETWEEN '值一' AND '值二';
		Between
		
	not between BETWEEN '值一' AND '值二';
		NotBetween


		or 查询示例

		UsersOrderExample example = new UsersOrderExample();
		UsersOrderExample.Criteria criteria = example.createCriteria(); 	
		UsersOrderExample.Criteria criteria2 = example.createCriteria(); 	

		criteria.andStatusEqualTo(1);
		criteria.andUidEqualTo(1);
		criteria.andTypeEqualTo(2);
		
		criteria2.andStatusEqualTo(2);
		criteria2.andUidEqualTo(1);
		criteria2.andTypeEqualTo(2);
		
		example.or(criteria2);//重点


你可能感兴趣的:(mybatis自动生成带的Example用法)