欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ibatis的动态查询

程序员文章站 2022-05-23 12:55:13
...
 TestTableExample example = new TestTableExample(); 
 
  example.createCriteria() 
    .andField1EqualTo(5) 
    .andField2IsNull(); 
 
  example.or(example.createCriteria() 
    .andField3NotEqualTo(9) 
    .andField4IsNotNull()); 
 
  List<Integer> field5Values = new ArrayList<Integer>(); 
  field5Values.add(8); 
  field5Values.add(11); 
  field5Values.add(14); 
  field5Values.add(22); 
 
  example.or(example.createCriteria() 
    .andField5In(field5Values)); 
 
  example.or(example.createCriteria() 
    .andField6Between(3, 7)); 

 

  • 产生条件:
 where (field1 = 5 and field2 is null) 
     or (field3 <> 9 and field4 is not null) 
     or (field5 in (8, 11, 14, 22)) 
     or (field6 between 3 and 7) 

  

相关标签: iBATIS