Commit 5662c7f9 authored by hewei's avatar hewei

版本说明

parent 7e403d1d
...@@ -18,7 +18,7 @@ Maven引用: ...@@ -18,7 +18,7 @@ Maven引用:
<dependency> <dependency>
<groupId>com.itfsw</groupId> <groupId>com.itfsw</groupId>
<artifactId>mybatis-generator-plugin</artifactId> <artifactId>mybatis-generator-plugin</artifactId>
<version>1.0.3</version> <version>1.0.4</version>
</dependency> </dependency>
``` ```
--------------------------------------- ---------------------------------------
...@@ -124,6 +124,19 @@ public class TbExample { ...@@ -124,6 +124,19 @@ public class TbExample {
offset = null; offset = null;
} }
} }
public class Test {
public static void main(String[] args) {
this.tbMapper.selectByExample(
new TbExample()
.createCriteria()
.andField1GreaterThan(1)
.example()
.limit(10) // 查询前10条
.limit(10, 10) // 查询10~20条
.page(1, 10) // 查询第2页数据(每页10条)
);
}
}
``` ```
### 3. 数据Model链式构建插件 ### 3. 数据Model链式构建插件
这个是仿jquery的链式调用强化了表的Model的赋值操作 这个是仿jquery的链式调用强化了表的Model的赋值操作
...@@ -184,13 +197,13 @@ public class Test { ...@@ -184,13 +197,13 @@ public class Test {
this.tbMapper.selectByExample(oldEx); this.tbMapper.selectByExample(oldEx);
// new // new
TbExample newEx; this.tbMapper.selectByExample(
newEx = 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.CriteriaAdd() { .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)
...@@ -202,8 +215,24 @@ public class Test { ...@@ -202,8 +215,24 @@ public class Test {
.andField3EqualTo(2) .andField3EqualTo(2)
.andField4EqualTo(new Date()) .andField4EqualTo(new Date())
) )
.example(); .example()
this.tbMapper.selectByExample(newEx); );
// -----------------------------------orderBy-----------------------------------
// old
TbExample ex = new TbExample();
ex.createCriteria().andField1GreaterThan(1);
ex.setOrderByClause("field1 DESC");
this.tbMapper.selectByExample(ex);
// new
this.tbMapper.selectByExample(
new TbExample()
.createCriteria()
.andField1GreaterThan(1)
.example()
.orderBy("field1 DESC")
);
} }
} }
``` ```
......
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