-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding `FilterRule` for custom criteria queries with cursors
- Loading branch information
Showing
15 changed files
with
443 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
cursorpaging-jpa/src/main/java/io/vigier/cursorpaging/jpa/FilterRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.vigier.cursorpaging.jpa; | ||
|
||
import jakarta.persistence.criteria.Predicate; | ||
|
||
|
||
/** | ||
* A custom rule to filter the query. | ||
*/ | ||
public interface FilterRule { | ||
|
||
default void applyQuery( final QueryBuilder cqb ) { | ||
cqb.addWhere( getPredicate( cqb ) ); | ||
} | ||
|
||
default void applyCount( final QueryBuilder cqb ) { | ||
cqb.addWhere( getCountPredicate( cqb ) ); | ||
} | ||
|
||
/** | ||
* Sometimes the query-predicate must be different than the count-predicate due to the criteria API | ||
* | ||
* @param cqb Query, Builder and Root | ||
* @return the predicate which should be applied to the where-clause | ||
*/ | ||
default Predicate getCountPredicate( final QueryBuilder cqb ) { | ||
return getPredicate( cqb ); | ||
} | ||
|
||
/** | ||
* Get the predicate for the query. | ||
* | ||
* @param cqb Query, Builder and Root | ||
* @return the predicate which should be applied to the where-clause | ||
*/ | ||
Predicate getPredicate( final QueryBuilder cqb ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
cursorpaging-jpa/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Auto Configure | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
io.vigier.cursorpaging.jpa.config.CursorPageAutoConfigure | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.vigier.cursorpaging.jpa.config.CursorPageAutoConfigure | ||
org.springframework.data.repository.core.support.RepositoryFactorySupport=io.vigier.cursorpaging.jpa.bootstrap.CursorPageJpaRepositoryFactory |
Oops, something went wrong.