2
2
3
3
# jpa-spec
4
4
5
+ ### Features
6
+
7
+ * Compatible with JPA 2 interface.
8
+ * Equal/NotEqual/Like support multiple values, Equal/NotEqual support ** Null** value.
9
+ * Builder style specification creator.
10
+
11
+
12
+ ### JPA 2 criteria API introduction
13
+
5
14
JPA 2 introduces a criteria API that can be used to build queries programmatically.
6
15
7
16
Writing a criteria you actually define the where-clause of a query for a domain class.
@@ -32,7 +41,7 @@ repositories {
32
41
}
33
42
34
43
dependencies {
35
- compile 'com.github.wenhao:jpa-spec:2.0.6 '
44
+ compile 'com.github.wenhao:jpa-spec:2.0.7 '
36
45
}
37
46
```
38
47
@@ -44,7 +53,7 @@ add repository [http://jcenter.bintray.com](http://jcenter.bintray.com) to maven
44
53
<dependency >
45
54
<groupId >com.github.wenhao</groupId >
46
55
<artifactId >jpa-spec</artifactId >
47
- <version >2.0.6 </version >
56
+ <version >2.0.7 </version >
48
57
</dependency >
49
58
```
50
59
@@ -76,7 +85,7 @@ Specification<Person> specification = new Specifications<Person>()
76
85
.like(" nickName" , " %og" , " %me" )
77
86
.build();
78
87
79
- personRepository. findAll(specification, new PageRequest (0 , 15 ));
88
+ Page< Person > persons = personRepository. findAll(specification, new PageRequest (0 , 15 ));
80
89
```
81
90
82
91
####Equal/NotEqual Example
@@ -107,7 +116,7 @@ Specification<Person> specification = new Specifications<Person>()
107
116
.gt(Objects . nonNull(person. getAge()), " age" , 18 )
108
117
.build();
109
118
110
- personRepository. findAll(specification, new PageRequest (0 , 15 ));
119
+ Page< Person > persons = personRepository. findAll(specification, new PageRequest (0 , 15 ));
111
120
```
112
121
113
122
####Between Example
@@ -139,5 +148,6 @@ Specification<Person> specification = new Specifications<Person>()
139
148
140
149
Sort sort = new Sort (new Order (DESC , " name" ), new Order (ASC , " birthday" ));
141
150
142
- personRepository. findAll(specification, new PageRequest (0 , 15 , sort));
151
+ Page<Person > persons = personRepository. findAll(specification, new PageRequest (0 , 15 , sort));
152
+ long totalCount = personRepository. count(specification);
143
153
```
0 commit comments