Package de.xima.fc.dao.utils
Class CriteriaApiHelper
- java.lang.Object
-
- de.xima.fc.dao.utils.CriteriaApiHelper
-
public class CriteriaApiHelper extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCriteriaApiHelper.DeleteCtx<QT>Wraps theEntityManagerprovided by the entity context, aCriteriaBuilderand aCriteriaDelete.static classCriteriaApiHelper.SelectCtx<QT>Wraps theEntityManagerprovided by the entity context, aCriteriaBuilderand aCriteriaQuery.static classCriteriaApiHelper.UpdateCtx<QT>Wraps theEntityManagerprovided by the entity context, aCriteriaBuilderand aCriteriaUpdate.
-
Constructor Summary
Constructors Constructor Description CriteriaApiHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.persistence.criteria.PredicateandCombinePredicates(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Predicate... predicates)Combines multiple predicates with an AND operation.static <QT> CriteriaApiHelper.DeleteCtx<QT>deleteCtx(IEntityContext ec)Creates a 'delete context' from the provided entity context.static javax.persistence.criteria.PredicateorCombinePredicates(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Predicate... predicates)Combines multiple predicates into a single OR predicate.static <QT> CriteriaApiHelper.SelectCtx<QT>selectCtx(IEntityContext ec)Creates a 'select context' from the provided entity context.static <QT> CriteriaApiHelper.SelectCtx<QT>selectCtx(IEntityContext ec, Function<javax.persistence.criteria.CriteriaBuilder,javax.persistence.criteria.CriteriaQuery<QT>> cqFunc)Creates a 'select context' from the provided entity context.static <QT> CriteriaApiHelper.UpdateCtx<QT>updateCtx(IEntityContext ec)Creates an 'update context' from the provided entity context.
-
-
-
Method Detail
-
andCombinePredicates
public static javax.persistence.criteria.Predicate andCombinePredicates(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Predicate... predicates)Combines multiple predicates with an AND operation.- Parameters:
cb- Criteria builderpredicates- Predicates to combine- Returns:
- Combined predicate
-
orCombinePredicates
public static javax.persistence.criteria.Predicate orCombinePredicates(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Predicate... predicates)Combines multiple predicates into a single OR predicate.- Parameters:
predicates- Predicates to combinecb- Criteria builder- Returns:
- Combined OR predicate
-
selectCtx
public static <QT> CriteriaApiHelper.SelectCtx<QT> selectCtx(IEntityContext ec)
Creates a 'select context' from the provided entity context.- Type Parameters:
QT- the query type (usually the type of the entity to query).- Parameters:
ec- the entity context to use- Returns:
- the resulting
CriteriaApiHelper.SelectCtx(wrapping theEntityManagerprovided by the entity context, aCriteriaBuilderand aCriteriaQuery).
-
selectCtx
public static <QT> CriteriaApiHelper.SelectCtx<QT> selectCtx(IEntityContext ec, Function<javax.persistence.criteria.CriteriaBuilder,javax.persistence.criteria.CriteriaQuery<QT>> cqFunc)
Creates a 'select context' from the provided entity context.- Type Parameters:
QT- the query type.- Parameters:
ec- the entity context to usecqFunc- function to create the criteria query (for cases where the criteria query's type is not entity based, e.g. when querying attributes using a multiselect and tuple query).- Returns:
- the resulting
CriteriaApiHelper.SelectCtx(wrapping theEntityManagerprovided by the entity context, aCriteriaBuilderand aCriteriaQuery).
-
deleteCtx
public static <QT> CriteriaApiHelper.DeleteCtx<QT> deleteCtx(IEntityContext ec)
Creates a 'delete context' from the provided entity context.- Type Parameters:
QT- the query type (usually the type of the entity to delete).- Parameters:
ec- the entity context to use- Returns:
- the resulting
CriteriaApiHelper.SelectCtx(wrapping theEntityManagerprovided by the entity context, aCriteriaBuilderand aCriteriaDelete).
-
updateCtx
public static <QT> CriteriaApiHelper.UpdateCtx<QT> updateCtx(IEntityContext ec)
Creates an 'update context' from the provided entity context.- Type Parameters:
QT- the query type (usually the type of the entity to update).- Parameters:
ec- the entity context to use- Returns:
- the resulting
CriteriaApiHelper.SelectCtx(wrapping theEntityManagerprovided by the entity context, aCriteriaBuilderand anCriteriaUpdate).
-
-