Interface CriteriaProjectionBuilder
- All Known Implementing Classes:
MetadataCriteriaProjectionBuilder
public interface CriteriaProjectionBuilder
Builds JPA Criteria queries that project entity data directly into DTOs.
-
Method Summary
Modifier and TypeMethodDescription<T,D> jakarta.persistence.criteria.CriteriaQuery <D> build(jakarta.persistence.criteria.CriteriaBuilder cb, Class<T> entityType, Class<D> dtoType, ProjectionQuery<T> query) Builds a JPA Criteria query for the given entity type and DTO type.<D> jakarta.persistence.criteria.Selection<D> construct(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, ?> from, Class<D> dtoType) Constructs a JPA Criteria selection for the given DTO type.
-
Method Details
-
build
<T,D> jakarta.persistence.criteria.CriteriaQuery<D> build(jakarta.persistence.criteria.CriteriaBuilder cb, Class<T> entityType, Class<D> dtoType, ProjectionQuery<T> query) Builds a JPA Criteria query for the given entity type and DTO type. This method constructs a CriteriaQuery that selects the DTO type based on the provided ProjectionQuery.- Type Parameters:
T- the type of the entityD- the type of the DTO- Parameters:
cb- the CriteriaBuilder to use for constructing the queryentityType- the type of the entity to project fromdtoType- the type of the DTO to project intoquery- the ProjectionQuery containing projection details- Returns:
- a CriteriaQuery that projects entity data into DTOs
-
construct
<D> jakarta.persistence.criteria.Selection<D> construct(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, ?> from, Class<D> dtoType) Constructs a JPA Criteria selection for the given DTO type. If the metadata is available, it uses that to construct the selection; otherwise, it falls back to using the ProjectionMapper.- Type Parameters:
D- the type of the DTO- Parameters:
cb- the CriteriaBuilder to use for constructing selectionsfrom- the 'From' object representing the root entitydtoType- the type of the DTO to project into- Returns:
- a Selection that constructs the DTO from the entity paths
-