Class JpaPaymentTransactionRepoUtility

java.lang.Object
com.broadleafcommerce.paymenttransaction.provider.jpa.repository.JpaPaymentTransactionRepoUtility

public final class JpaPaymentTransactionRepoUtility extends Object
Utility class for working with queries in PaymentTransaction related repositories. Conversion of queries based on contextual information (such as DB platform) may be taken into account.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <D> org.springframework.data.domain.Page<D>
    convertResultsIfApplicable(org.springframework.data.domain.Pageable pageable, jakarta.persistence.criteria.CriteriaBuilder cb, org.springframework.data.domain.Page<D> results, jakarta.persistence.EntityManager entityManager, Class<D> managedType)
    In the case of Oracle, this conversion method will take a page of results (assumed to contain primary key values) and convert to a page of fully hydrated entities.
    static <D> jakarta.persistence.criteria.CriteriaQuery<?>
    createCriteria(jakarta.persistence.criteria.CriteriaBuilder cb, Class<D> type, jakarta.persistence.EntityManager entityManager)
    Similar to setSelection(CriteriaQuery, Root, EntityManager) in regard to Oracle compatibility.
    static <D> void
    setSelection(jakarta.persistence.criteria.CriteriaQuery criteria, jakarta.persistence.criteria.Root<D> root, jakarta.persistence.EntityManager entityManager)
    In the case of Oracle, this conversion method will set a query selection as contextId.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • convertResultsIfApplicable

      public static <D> org.springframework.data.domain.Page<D> convertResultsIfApplicable(@Nullable org.springframework.data.domain.Pageable pageable, jakarta.persistence.criteria.CriteriaBuilder cb, org.springframework.data.domain.Page<D> results, jakarta.persistence.EntityManager entityManager, Class<D> managedType)
      In the case of Oracle, this conversion method will take a page of results (assumed to contain primary key values) and convert to a page of fully hydrated entities. This is a useful workaround for Oracle when using queries with the Distinct keyword, as Oracle will fail to pull results if the entity contains one or more CLOB fields.
      Type Parameters:
      D - The type of entity that is returned
      Parameters:
      pageable - The page requested
      cb - The CriteriaBuilder instance for creating JPA Criteria queries
      results - The page of results of a previous query that returns only primary key values (workaround Oracle issue)
      entityManager - The EntityManager instance for persistence interaction
      managedType - The type of entity that is returned
      Returns:
      The page of results matching the managedType with the primary keys passed in via results
    • setSelection

      public static <D> void setSelection(jakarta.persistence.criteria.CriteriaQuery criteria, jakarta.persistence.criteria.Root<D> root, jakarta.persistence.EntityManager entityManager)
      In the case of Oracle, this conversion method will set a query selection as contextId. Otherwise, it will set the selection as the root type. This is useful to cause a query to provide a list of primary key results only, which can be used to feed the input of convertResultsIfApplicable(Pageable, CriteriaBuilder, Page, EntityManager, Class).
      Type Parameters:
      D - The root entity type
      Parameters:
      criteria - The JPA Criteria instance for the candidate query
      root - The root type for the Criteria
      entityManager - The EntityManager instance for persistence interaction
    • createCriteria

      public static <D> jakarta.persistence.criteria.CriteriaQuery<?> createCriteria(jakarta.persistence.criteria.CriteriaBuilder cb, Class<D> type, jakarta.persistence.EntityManager entityManager)
      Similar to setSelection(CriteriaQuery, Root, EntityManager) in regard to Oracle compatibility. Serves to set the query result type to String (for primary keys) for Oracle, but leave it at the root domain type for other platforms.
      Type Parameters:
      D - The type of entity that is returned under normal circumstances (i.e. not the Oracle edge case)
      Parameters:
      cb - The CriteriaBuilder instance for creating JPA Criteria queries
      type - The type of entity that is returned under normal circumstances (i.e. not the Oracle edge case)
      entityManager - The EntityManager instance for persistence interaction
      Returns:
      The new CriteriaQuery instance. It will be a String type query if the Oracle edge case is activated.