Skip to content

Commit 14db1aa

Browse files
committed
Merge remote-tracking branch 'remotes/origin/dev'
2 parents 123b983 + 54580e2 commit 14db1aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4474
-3655
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,22 @@ public class UserRepositoryIntegrationTests {
345345
}
346346
}
347347
```
348+
QueryObject `UserQuery`
349+
```java
350+
@Data
351+
@IncludeFields("emailAddress")
352+
public class UserQuery {
353+
@ExprParam(expr = ExprType.CONTAINS)
354+
private String emailAddress;
355+
356+
@ExprParam(name = "age", expr = ExprType.GE)
357+
private int ageStart;
358+
359+
@ExprParam(name = "age", expr = ExprType.LE)
360+
private int ageEnd;
361+
}
362+
```
363+
348364
`EbeanQueryChannelServiceIntegrationTests.java`
349365
```java
350366
package org.springframework.data.ebean.querychannel;
@@ -444,6 +460,31 @@ public class EbeanQueryChannelServiceIntegrationTests {
444460
assertEquals("QueryChannel", userDTO.getFirstName());
445461
assertEquals("[email protected]", userDTO.getEmailAddress());
446462
}
463+
464+
@Test
465+
public void query_queryObject() {
466+
UserQuery userQuery = new UserQuery();
467+
userQuery.setEmailAddress("[email protected]");
468+
userQuery.setAgeStart(1);
469+
userQuery.setAgeEnd(30);
470+
UserDTO user = queryChannel.createQuery(User.class, userQuery)
471+
.asDto(UserDTO.class)
472+
.setRelaxedMode()
473+
.findOne();
474+
assertEquals("[email protected]", user.getEmailAddress());
475+
}
476+
477+
@Test
478+
public void applyQueryObject() {
479+
UserQuery userQuery = new UserQuery();
480+
userQuery.setEmailAddress("[email protected]");
481+
userQuery.setAgeStart(1);
482+
userQuery.setAgeEnd(30);
483+
UserInfo userInfo = EbeanQueryChannelService.applyWhere(queryChannel.createNamedQuery(UserInfo.class,
484+
"userInfo").where(), userQuery).findOne();
485+
assertEquals("QueryChannel", userInfo.getFirstName());
486+
assertEquals("[email protected]", userInfo.getEmailAddress());
487+
}
447488

448489
}
449490
```

README_zh.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,22 @@ public class UserRepositoryIntegrationTests {
309309
}
310310
}
311311
```
312+
查询对象 `UserQuery`
313+
```java
314+
@Data
315+
@IncludeFields("emailAddress")
316+
public class UserQuery {
317+
@ExprParam(expr = ExprType.CONTAINS)
318+
private String emailAddress;
319+
320+
@ExprParam(name = "age", expr = ExprType.GE)
321+
private int ageStart;
322+
323+
@ExprParam(name = "age", expr = ExprType.LE)
324+
private int ageEnd;
325+
}
326+
```
327+
```
312328
`EbeanQueryChannelServiceIntegrationTests.java`
313329
```java
314330
package org.springframework.data.ebean.querychannel;
@@ -408,6 +424,31 @@ public class EbeanQueryChannelServiceIntegrationTests {
408424
assertEquals("QueryChannel", userDTO.getFirstName());
409425
assertEquals("[email protected]", userDTO.getEmailAddress());
410426
}
427+
428+
@Test
429+
public void query_queryObject() {
430+
UserQuery userQuery = new UserQuery();
431+
userQuery.setEmailAddress("[email protected]");
432+
userQuery.setAgeStart(1);
433+
userQuery.setAgeEnd(30);
434+
UserDTO user = queryChannel.createQuery(User.class, userQuery)
435+
.asDto(UserDTO.class)
436+
.setRelaxedMode()
437+
.findOne();
438+
assertEquals("[email protected]", user.getEmailAddress());
439+
}
440+
441+
@Test
442+
public void applyQueryObject() {
443+
UserQuery userQuery = new UserQuery();
444+
userQuery.setEmailAddress("[email protected]");
445+
userQuery.setAgeStart(1);
446+
userQuery.setAgeEnd(30);
447+
UserInfo userInfo = EbeanQueryChannelService.applyWhere(queryChannel.createNamedQuery(UserInfo.class,
448+
"userInfo").where(), userQuery).findOne();
449+
assertEquals("QueryChannel", userInfo.getFirstName());
450+
assertEquals("[email protected]", userInfo.getEmailAddress());
451+
}
411452
412453
}
413454
```

pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.hexagonframework.data</groupId>
88
<artifactId>spring-data-ebean</artifactId>
9-
<version>1.3.4.RELEASE</version>
9+
<version>1.4.0.RELEASE</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Spring Data Ebean</name>
@@ -40,6 +40,9 @@
4040
</scm>
4141

4242
<properties>
43+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
44+
<java.version>1.8</java.version>
45+
<ebean-maven-plugin.args>debug=0</ebean-maven-plugin.args>
4346
<bundlor.enabled>false</bundlor.enabled>
4447
<bundlor.failOnWarnings>false</bundlor.failOnWarnings>
4548
<spring>5.0.4.RELEASE</spring>
@@ -70,7 +73,7 @@
7073
<groupId>org.apache.maven.plugins</groupId>
7174
<artifactId>maven-javadoc-plugin</artifactId>
7275
<configuration>
73-
<source>1.8</source>
76+
<source>${java.version}</source>
7477
</configuration>
7578
<executions>
7679
<execution>
@@ -207,12 +210,12 @@
207210
<plugin>
208211
<groupId>io.repaint.maven</groupId>
209212
<artifactId>tiles-maven-plugin</artifactId>
210-
<version>2.8</version>
213+
<version>2.10</version>
211214
<extensions>true</extensions>
212215
<configuration>
213216
<tiles>
214217
<tile>org.avaje.tile:java-compile:1.1</tile>
215-
<tile>io.ebean.tile:enhancement:5.1</tile>
218+
<tile>io.ebean.tile:enhancement:5.5</tile>
216219
</tiles>
217220
</configuration>
218221
</plugin>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.springframework.data.ebean.annotation;
2+
3+
import org.springframework.data.ebean.querychannel.ExprType;
4+
5+
import java.lang.annotation.*;
6+
7+
/**
8+
* Expr param.
9+
*
10+
* @author XueguiYuan
11+
* @version 1.0 (created time: 2018/4/29).
12+
*/
13+
@Retention(RetentionPolicy.RUNTIME)
14+
@Target(ElementType.FIELD)
15+
@Documented
16+
public @interface ExprParam {
17+
18+
/**
19+
* Query param name.
20+
*/
21+
String name() default "";
22+
23+
/**
24+
* Query param name.
25+
*/
26+
String value() default "";
27+
28+
/**
29+
* Expr.
30+
*/
31+
ExprType expr() default ExprType.DEFAULT;
32+
33+
/**
34+
* Case insensitive.
35+
*/
36+
boolean ignoreCase() default true;
37+
38+
/**
39+
* If true, do nothing when field value is null, else and expr isNull.
40+
*/
41+
boolean escapeNull() default true;
42+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.springframework.data.ebean.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* Define the fetch path string for query select and fetch.
10+
*
11+
* @author XueguiYuan
12+
* @version 1.0 (created time: 2018/4/29).
13+
*/
14+
@Retention(RetentionPolicy.RUNTIME)
15+
@Target(ElementType.TYPE)
16+
public @interface IncludeFields {
17+
/**
18+
* Query fetch path string.
19+
*/
20+
String value();
21+
}

src/main/java/org/springframework/data/ebean/annotation/Modifying.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@
1616

1717
package org.springframework.data.ebean.annotation;
1818

19-
import java.lang.annotation.Documented;
20-
import java.lang.annotation.ElementType;
21-
import java.lang.annotation.Retention;
22-
import java.lang.annotation.RetentionPolicy;
23-
import java.lang.annotation.Target;
19+
import java.lang.annotation.*;
2420

2521
/**
26-
* Indicates a method should be regarded as Update{@link io.ebean.UpdateQuery} or SqlUpdate {@link io.ebean.SqlUpdate}.
22+
* Indicates a method should be regarded as Update{@link io.ebean.UpdateQuery} or SqlUpdate{@link io.ebean.SqlUpdate}.
2723
*
2824
* @author Xuegui Yuan
2925
*/
3026
@Retention(RetentionPolicy.RUNTIME)
31-
@Target( {ElementType.METHOD, ElementType.ANNOTATION_TYPE})
27+
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
3228
@Documented
3329
public @interface Modifying {
3430
}

src/main/java/org/springframework/data/ebean/annotation/Procedure.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/main/java/org/springframework/data/ebean/annotation/Query.java

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,34 @@
1616

1717
package org.springframework.data.ebean.annotation;
1818

19-
import java.lang.annotation.Documented;
20-
import java.lang.annotation.ElementType;
21-
import java.lang.annotation.Retention;
22-
import java.lang.annotation.RetentionPolicy;
23-
import java.lang.annotation.Target;
2419
import org.springframework.data.annotation.QueryAnnotation;
2520

21+
import java.lang.annotation.*;
22+
2623
/**
2724
* Annotation to declare finder queries directly on repository methods.
2825
*
2926
* @author Xuegui Yuan
3027
*/
3128
@Retention(RetentionPolicy.RUNTIME)
32-
@Target( {ElementType.METHOD, ElementType.ANNOTATION_TYPE})
29+
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
3330
@QueryAnnotation
3431
@Documented
3532
public @interface Query {
3633

37-
/**
38-
* Defines the Ebean query to be executed when the annotated method is called.
39-
*/
40-
String value() default "";
41-
42-
/**
43-
* Configures whether the given query is a SqlQuery. Defaults to {@literal false}.
44-
*/
45-
boolean nativeQuery() default false;
34+
/**
35+
* Defines the Ebean query to be executed when the annotated method is called.
36+
*/
37+
String value() default "";
4638

47-
/**
48-
* The named query to be used. If not defined, a {@link javax.persistence.NamedQuery} with name of
49-
* {@code $ domainClass}.${queryMethodName}} will be used.
50-
*/
51-
String name() default "";
39+
/**
40+
* Configures whether the given query is a SqlQuery. Defaults to {@literal false}.
41+
*/
42+
boolean nativeQuery() default false;
5243

53-
/**
54-
* Parse the string to return a FetchPath,
55-
* format like (a,b,c(d,e),f(g)) where "c" is a path containing "d" and "e" and "f" is a
56-
* path containing "g" and the root path contains "a","b","c" and "f".
57-
*/
58-
String fetchPath() default "";
44+
/**
45+
* The named query to be used. If not defined, a {@link javax.persistence.NamedQuery} with name of
46+
* {@code $ domainClass}.${queryMethodName}} will be used.
47+
*/
48+
String name() default "";
5949
}

0 commit comments

Comments
 (0)