Class CriteriaApiHelper


  • public class CriteriaApiHelper
    extends Object
    • Constructor Detail

      • CriteriaApiHelper

        public CriteriaApiHelper()
    • 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 builder
        predicates - 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 combine
        cb - 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 the EntityManager provided by the entity context, a CriteriaBuilder and a CriteriaQuery).
      • 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 use
        cqFunc - 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 the EntityManager provided by the entity context, a CriteriaBuilder and a CriteriaQuery).
      • 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 the EntityManager provided by the entity context, a CriteriaBuilder and a CriteriaDelete).
      • 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 the EntityManager provided by the entity context, a CriteriaBuilder and an CriteriaUpdate).