Class QueryHelper
- java.lang.Object
-
- com.devonfw.module.jpa.dataaccess.api.QueryHelper
-
- Direct Known Subclasses:
QueryUtil
public class QueryHelper extends Object
Class with utility methods for dealing with queries. Either extend this class or useQueryUtil.get().- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringQUERY_PROPERTY_TIMEOUTJPA query property to configure the timeout in milliseconds.
-
Constructor Summary
Constructors Constructor Description QueryHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplySort(com.querydsl.jpa.impl.JPAQuery<?> query, org.springframework.data.domain.Sort sort)protected voidapplyTimeout(com.querydsl.jpa.impl.JPAQuery<?> query, Number timeout)protected <E> org.springframework.data.domain.Page<E>findPaginatedGeneric(org.springframework.data.domain.Pageable pageable, com.querydsl.jpa.impl.JPAQuery<E> query, boolean determineTotal)Returns aPageof entities according to the suppliedPageableandJPAQuery.protected <T> com.querydsl.core.types.dsl.BooleanExpressionnewInClause(com.querydsl.core.types.dsl.SimpleExpression<T> expression, Collection<T> inValues)protected com.querydsl.core.types.dsl.BooleanExpressionnewLikeClause(com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)protected com.querydsl.core.types.dsl.BooleanExpressionnewLikeClause(com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring, boolean negate)protected com.querydsl.core.types.dsl.BooleanExpressionnewNotLikeClause(com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)protected com.querydsl.core.types.dsl.BooleanExpressionnewStringClause(com.querydsl.core.types.dsl.StringExpression expression, String value, StringSearchConfigTo config)protected com.querydsl.core.types.dsl.BooleanExpressionnewStringClause(com.querydsl.core.types.dsl.StringExpression expression, String value, StringSearchOperator operator, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)protected <T> voidwhereIn(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.SimpleExpression<T> expression, Collection<T> inValues)protected voidwhereLike(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)protected voidwhereNotLike(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)protected voidwhereString(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.StringExpression expression, String value, StringSearchConfigTo config)
-
-
-
Field Detail
-
QUERY_PROPERTY_TIMEOUT
protected static final String QUERY_PROPERTY_TIMEOUT
JPA query property to configure the timeout in milliseconds.- See Also:
- Constant Field Values
-
-
Method Detail
-
applyTimeout
protected void applyTimeout(com.querydsl.jpa.impl.JPAQuery<?> query, Number timeout)- Parameters:
query- theJPAQueryto modify.timeout- the timeout in milliseconds.
-
whereLike
protected void whereLike(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)- Parameters:
query- theJPAQueryto modify.expression- theStringExpressiontocreate the LIKE-clausefrom.pattern- the pattern for the LIKE-clause to create.syntax- theLikePatternSyntaxof the givenpattern.ignoreCase- -trueto ignore the case,falseotherwise (to search case-sensitive).matchSubstring- -trueto match also if the givenpatternshall also match substrings on the givenStringExpression.
-
whereNotLike
protected void whereNotLike(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)- Parameters:
query- theJPAQueryto modify.expression- theStringExpressiontocreate the NOT LIKE-clausefrom.pattern- the pattern for the NOT LIKE-clause to create.syntax- theLikePatternSyntaxof the givenpattern.ignoreCase- -trueto ignore the case,falseotherwise (to search case-sensitive).matchSubstring- -trueto match also if the givenpatternshall also match substrings on the givenStringExpression.
-
newLikeClause
protected com.querydsl.core.types.dsl.BooleanExpression newLikeClause(com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)- Parameters:
expression- theStringExpressiontocreate the LIKE-clausefrom.pattern- the pattern for the LIKE-clause to create.syntax- theLikePatternSyntaxof the givenpattern.ignoreCase- -trueto ignore the case,falseotherwise (to search case-sensitive).matchSubstring- -trueto match also if the givenpatternshall also match substrings on the givenStringExpression.- Returns:
- the LIKE-clause as
BooleanExpression.
-
newNotLikeClause
protected com.querydsl.core.types.dsl.BooleanExpression newNotLikeClause(com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)- Parameters:
expression- theStringExpressiontocreate the NOT LIKE-clausefrom.pattern- the pattern for the NOT LIKE-clause to create.syntax- theLikePatternSyntaxof the givenpattern.ignoreCase- -trueto ignore the case,falseotherwise (to search case-sensitive).matchSubstring- -trueto match also if the givenpatternshall also match substrings on the givenStringExpression.- Returns:
- the NOT LIKE-clause as
BooleanExpression.
-
newLikeClause
protected com.querydsl.core.types.dsl.BooleanExpression newLikeClause(com.querydsl.core.types.dsl.StringExpression expression, String pattern, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring, boolean negate)- Parameters:
expression- theStringExpressiontocreate the LIKE-clausefrom.pattern- the pattern for the LIKE-clause to create.syntax- theLikePatternSyntaxof the givenpattern.ignoreCase- -trueto ignore the case,falseotherwise (to search case-sensitive).matchSubstring- -trueto match also if the givenpatternshall also match substrings on the givenStringExpression.negate- -trueforNOT LIKE,falseforLIKE.- Returns:
- the LIKE-clause as
BooleanExpression.
-
newStringClause
protected com.querydsl.core.types.dsl.BooleanExpression newStringClause(com.querydsl.core.types.dsl.StringExpression expression, String value, StringSearchConfigTo config)- Parameters:
expression- theStringExpressionto search on.value- the string value or pattern to search for.config- theStringSearchConfigToto configure the search. May benullfor regular equals search as default fallback.- Returns:
- the new
BooleanExpressionfor the specified string comparison clause.
-
newStringClause
protected com.querydsl.core.types.dsl.BooleanExpression newStringClause(com.querydsl.core.types.dsl.StringExpression expression, String value, StringSearchOperator operator, LikePatternSyntax syntax, boolean ignoreCase, boolean matchSubstring)- Parameters:
expression- theStringExpressionto search on.value- the string value or pattern to search for.syntax- theLikePatternSyntaxof the givenpattern.operator- theStringSearchOperatorused to compare the search stringvalue.ignoreCase- -trueto ignore the case,falseotherwise (to search case-sensitive).matchSubstring- -trueto match also if the givenpatternshall also match substrings on the givenStringExpression.- Returns:
- the new
BooleanExpressionfor the specified string comparison clause.
-
whereString
protected void whereString(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.StringExpression expression, String value, StringSearchConfigTo config)- Parameters:
query- theJPAQueryto modify.expression- theStringExpressionto search on.value- the string value or pattern to search for.config- theStringSearchConfigToto configure the search. May benullfor regular equals search.
-
newInClause
protected <T> com.querydsl.core.types.dsl.BooleanExpression newInClause(com.querydsl.core.types.dsl.SimpleExpression<T> expression, Collection<T> inValues)- Type Parameters:
T- generic type of theCollectionvalues for theIN-clause(s).- Parameters:
expression- theSimpleExpressionused to create theIN-clause(s).inValues- theCollectionof values for theIN-clause(s).- Returns:
- the
BooleanExpressionfor theIN-clause(s) odernullifinValuesisnullorempty.
-
whereIn
protected <T> void whereIn(com.querydsl.jpa.impl.JPAQuery<?> query, com.querydsl.core.types.dsl.SimpleExpression<T> expression, Collection<T> inValues)- Type Parameters:
T- generic type of theCollectionvalues for theIN-clause(s).- Parameters:
query- theJPAQuerywhere toaddtheIN-clause(s)from the other given parameters.expression- theSimpleExpressionused to create theIN-clause(s).inValues- theCollectionof values for theIN-clause(s).- See Also:
newInClause(SimpleExpression, Collection)
-
findPaginatedGeneric
protected <E> org.springframework.data.domain.Page<E> findPaginatedGeneric(org.springframework.data.domain.Pageable pageable, com.querydsl.jpa.impl.JPAQuery<E> query, boolean determineTotal)Returns aPageof entities according to the suppliedPageableandJPAQuery.- Type Parameters:
E- generic type of the entity.- Parameters:
pageable- contains information about the requested page and sorting.query- is a query which is pre-configured with the desired conditions for the search.determineTotal- -trueto determine thetotal number of hits,falseotherwise.- Returns:
- a paginated list.
-
applySort
protected void applySort(com.querydsl.jpa.impl.JPAQuery<?> query, org.springframework.data.domain.Sort sort)- Parameters:
query- theJPAQueryto apply theSortto.sort- theSortto apply as ORDER BY to the givenJPAQuery.
-
-