Class JpaPaymentTransactionRepoUtility
java.lang.Object
com.broadleafcommerce.paymenttransaction.provider.jpa.repository.JpaPaymentTransactionRepoUtility
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 TypeMethodDescriptionstatic <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 tosetSelection(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 ascontextId
.
-
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 theDistinct
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 requestedcb
- The CriteriaBuilder instance for creating JPA Criteria queriesresults
- The page of results of a previous query that returns only primary key values (workaround Oracle issue)entityManager
- The EntityManager instance for persistence interactionmanagedType
- The type of entity that is returned- Returns:
- The page of results matching the
managedType
with the primary keys passed in viaresults
-
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 ascontextId
. 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 ofconvertResultsIfApplicable(Pageable, CriteriaBuilder, Page, EntityManager, Class)
.- Type Parameters:
D
- The root entity type- Parameters:
criteria
- The JPA Criteria instance for the candidate queryroot
- The root type for the CriteriaentityManager
- 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 tosetSelection(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 queriestype
- 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.
-