File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
mapper/src/test/java/io/mybatis/mapper/base Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,17 @@ public void testOrCondition() {
144144 public void testExampleWrapper () {
145145 try (SqlSession sqlSession = getSqlSession ()) {
146146 UserMapper2 mapper = sqlSession .getMapper (UserMapper2 .class );
147+ Example <User > example = new Example <>();
148+ example .createCriteria ().andEqualTo (User ::getSex , "男" ).andOr (
149+ example .orPart ().andLike (User ::getUserName , "杨%" ),
150+ example .orPart ().le (User ::getId , 10 ));
151+ List <User > users1 = mapper .selectByExample (example );
152+
153+ List <User > list = mapper .wrapper ().eq (User ::getSex , "男" )
154+ .or (
155+ c -> c .startsWith (User ::getUserName , "杨" ),
156+ c -> c .le (User ::getId , 10 )).list ();
157+
147158 //查询 "sex=男 or name like '杨%' 的数量
148159 long count = mapper .wrapper ().eq (User ::getSex , "男" )
149160 .or (
You can’t perform that action at this time.
0 commit comments