Commit 51b8abee authored by hewei's avatar hewei

版本说明

parent 5662c7f9
...@@ -174,12 +174,13 @@ public class Test { ...@@ -174,12 +174,13 @@ public class Test {
public static void main(String[] args) { public static void main(String[] args) {
// -----------------------------------example----------------------------------- // -----------------------------------example-----------------------------------
// 表Example.Criteria增加了工厂方法example()支持,使用后可链式构建查询条件使用example()返回Example对象 // 表Example.Criteria增加了工厂方法example()支持,使用后可链式构建查询条件使用example()返回Example对象
TbExample ex = new TbExample() this.tbMapper.selectByExample(
.createCriteria() new TbExample()
.andField1EqualTo(1) .createCriteria()
.andField2EqualTo("xxx") .andField1EqualTo(1)
.example(); .andField2EqualTo("xxx")
this.tbMapper.selectByExample(ex); .example()
);
// -----------------------------------andIf----------------------------------- // -----------------------------------andIf-----------------------------------
// Criteria增强了链式调用,现在一些按条件增加的查询条件不会打乱链式调用了 // Criteria增强了链式调用,现在一些按条件增加的查询条件不会打乱链式调用了
...@@ -199,23 +200,23 @@ public class Test { ...@@ -199,23 +200,23 @@ public class Test {
// new // new
this.tbMapper.selectByExample( this.tbMapper.selectByExample(
new TbExample() new TbExample()
.createCriteria() .createCriteria()
.andField1EqualTo(1) .andField1EqualTo(1)
.andField2EqualTo("xxx") .andField2EqualTo("xxx")
// 如果随机数大于0.5,附加Field3查询条件 // 如果随机数大于0.5,附加Field3查询条件
.andIf(Math.random() > 0.5, new TbExample.Criteria.ICriteriaAdd() { .andIf(Math.random() > 0.5, new TbExample.Criteria.ICriteriaAdd() {
@Override @Override
public TbExample.Criteria add(TbExample.Criteria add) { public TbExample.Criteria add(TbExample.Criteria add) {
return add.andField3EqualTo(2) return add.andField3EqualTo(2)
.andField4EqualTo(new Date()); .andField4EqualTo(new Date());
} }
}) })
// 当然最简洁的写法是采用java8的Lambda表达式,当然你的项目是Java8+ // 当然最简洁的写法是采用java8的Lambda表达式,当然你的项目是Java8+
.andIf(Math.random() > 0.5, add -> add .andIf(Math.random() > 0.5, add -> add
.andField3EqualTo(2) .andField3EqualTo(2)
.andField4EqualTo(new Date()) .andField4EqualTo(new Date())
) )
.example() .example()
); );
// -----------------------------------orderBy----------------------------------- // -----------------------------------orderBy-----------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment