mybatis example 使用AND 和OR 联合查询
ViewPsmsgconsultExample example=new ViewPsmsgconsultExample(); ViewPsmsgconsultExample.Criteria criteria=example.createCriteria(); criteria.andToidEqualTo(mctid); criteria.andStatusEqualTo("0"); ViewPsmsgconsultExample.Criteria criteria2=example.createCriteria(); criteria2.andToidEqualTo(mctid); criteria2.andLaststatusEqualTo("0"); example.or(criteria2); psmsgconsultDao.countByExample(example);
生成代码如下:
select count(*) from VIEW_PSMSGCONSULT WHERE ( TOID = ? and STATUS = ? ) or( TOID = ? and LASTSTATUS = ? )