1.在Example中每一个criteria相当于一个括号,把里面的内容当作一个整体。
Where(userid=’1’and name=’2’)UserExample example = new UserExample();
UserExample.Criteria c1 = example.createCriteria();
C1.andUseridEqualTo(“1”);
C2.andNameEqualTo(“2”);
2.在criteria中没有直接的or。
(1)where(A and B) or (C and D)BasePointsExample.Criteria criteria1 = example.createCriteria();
criteria1.andUseridEqualTo('11');
criteria1.andPointnameLike(StringUtil.concatlike('22'));
BasePointsExample.Criteria criteria2 = example.createCriteria();
criteria2.andUsernameEqualTo('33');
criteria2.andPointcontentLike(StringUtil.concatlike('44'));
example.or(criteria2);
(2)where A and (B or C)
==>(A and B) or (A and C)BasePointsExample.Criteria criteria1 = example.createCriteria();
criteria1.andUseridEqualTo('11');
criteria1.andPointnameLike(StringUtil.concatlike('22'));
BasePointsExample.Criteria criteria2 = example.createCriteria();
criteria2.andUseridEqualTo('11');
criteria2.andPointcontentLike(StringUtil.concatlike('33'));
example.or(criteria2);