Skip to content

Commit

Permalink
[Wen Hao] - upgrade to 2.2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhao committed Oct 24, 2016
1 parent 5261c5b commit 0601b35
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,6 @@ public Page<Person> findAll(SearchRequest request) {
}
```

####Pagination and Sort

find person by pagination and sort by name desc and birthday asc.

```java
public Page<Person> findAll(SearchRequest request) {
Specification<Person> specification = new Specifications<Person>()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt("age", 18)
.between("birthday", new Range<>(new Date(), new Date()))
.like("nickName", "%og%")
.build();

Sort sort = new Sorts()
.desc(StringUtils.isNotBlank(request.getName()), "name")
.asc("birthday")
.build();

return personRepository.findAll(specification, new PageRequest(0, 15, sort));
}
```

####Join

every specification support association query as inner join.
Expand Down Expand Up @@ -206,7 +184,6 @@ public List<Phone> findAll(SearchRequest request) {
}
```
####Custom Specification
You can custom specification to do the @ManyToOne and @ManyToMany as well.
Expand Down Expand Up @@ -247,6 +224,28 @@ public List<Phone> findAll(SearchRequest request) {
}
```
####Pagination and Sort
find person by pagination and sort by name desc and birthday asc.
```java
public Page<Person> findAll(SearchRequest request) {
Specification<Person> specification = new Specifications<Person>()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt("age", 18)
.between("birthday", new Range<>(new Date(), new Date()))
.like("nickName", "%og%")
.build();
Sort sort = new Sorts()
.desc(StringUtils.isNotBlank(request.getName()), "name")
.asc("birthday")
.build();
return personRepository.findAll(specification, new PageRequest(0, 15, sort));
}
```
####Virtual View
Using **@org.hibernate.annotations.Subselect** to define a virtual view if you don't want a database table view.
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repositories {
}

group = 'com.github.wenhao'
version = '2.1.1-SNAPSHOT'
version = '2.2.0'

dependencies {
compile("org.springframework.data:spring-data-jpa:$springBootVersion")
Expand Down Expand Up @@ -71,10 +71,10 @@ bintray {
githubRepo = 'wenhao/jpa-spec'
githubReleaseNotesFile = 'README.md'
version {
name = '2.1.0'
desc = 'A JAP Query By Specification framework 2.1.0'
name = '2.2.0'
desc = 'A JAP Query By Specification framework 2.2.0'
released = new Date()
vcsTag = '2.1.0'
vcsTag = '2.2.0'
}
}
}
Expand All @@ -90,7 +90,7 @@ install {
packaging 'jar'
groupId 'com.github.wenhao'
artifactId 'jpa-spec'
version '2.1.0'
version '2.2.0'

licenses {
license {
Expand Down

0 comments on commit 0601b35

Please sign in to comment.