|
Spring Data Jpa | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.jpa.repository.query.QueryUtils
public abstract class QueryUtils
Simple utility class to create JPA queries.
Field Summary | |
---|---|
static String |
COUNT_QUERY_STRING
|
static String |
DELETE_ALL_QUERY_STRING
|
static String |
EXISTS_QUERY_STRING
|
static String |
READ_ALL_QUERY
|
Method Summary | ||
---|---|---|
static
|
applyAndBind(String queryString,
Iterable<T> entities,
javax.persistence.EntityManager entityManager)
Creates a where-clause referencing the given entities and appends it to the given query string. |
|
static String |
applySorting(String query,
Sort sort)
Adds order by clause to the JPQL query. |
|
static String |
applySorting(String query,
Sort sort,
String alias)
Adds order by clause to the JPQL query. |
|
static String |
createCountQueryFor(String originalQuery)
Creates a count projected query from the given orginal query. |
|
static String |
detectAlias(String query)
Resolves the alias for the entity to be retrieved from the given JPA query. |
|
static String |
getQueryString(String template,
String entityName)
Returns the query string for the given class name. |
|
static boolean |
hasNamedParameter(javax.persistence.Query query)
Returns whether the given Query contains named parameters. |
|
static String |
toJpaDirection(Sort.Order order)
|
|
static List<javax.persistence.criteria.Order> |
toOrders(Sort sort,
javax.persistence.criteria.Root<?> root,
javax.persistence.criteria.CriteriaBuilder cb)
Turns the given Sort into Order s. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COUNT_QUERY_STRING
public static final String EXISTS_QUERY_STRING
public static final String DELETE_ALL_QUERY_STRING
public static final String READ_ALL_QUERY
Method Detail |
---|
public static String getQueryString(String template, String entityName)
template
- entityName
-
public static String applySorting(String query, Sort sort)
DEFAULT_ALIAS
to bind the sorting property to.
query
- alias
- sort
-
public static String applySorting(String query, Sort sort, String alias)
query
- sort
- alias
-
public static String toJpaDirection(Sort.Order order)
public static String detectAlias(String query)
query
-
public static <T> javax.persistence.Query applyAndBind(String queryString, Iterable<T> entities, javax.persistence.EntityManager entityManager)
T
- queryString
- entities
- entityManager
-
public static String createCountQueryFor(String originalQuery)
originalQuery
- must not be null or empty
public static boolean hasNamedParameter(javax.persistence.Query query)
Query
contains named parameters.
query
-
public static List<javax.persistence.criteria.Order> toOrders(Sort sort, javax.persistence.criteria.Root<?> root, javax.persistence.criteria.CriteriaBuilder cb)
Sort
into Order
s.
sort
- the Sort
instance to be transformed into JPA Order
s.root
- must not be null.cb
- must not be null.
|
Spring Data Jpa | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |