Class JpaProjectionExecutor
java.lang.Object
nl.datasteel.crudcraft.projection.impl.jpa.JpaProjectionExecutor
- All Implemented Interfaces:
ProjectionExecutor
JPA-based implementation of
ProjectionExecutor
using Criteria API.-
Constructor Summary
ConstructorsConstructorDescriptionJpaProjectionExecutor
(jakarta.persistence.EntityManager entityManager, CriteriaProjectionBuilder projectionBuilder, ProjectionMetadataRegistry metadataRegistry) Constructs a new JpaProjectionExecutor with the given parameters. -
Method Summary
Modifier and TypeMethodDescription<T,
D> ProjectionResult <D> project
(Class<T> entityType, Class<D> dtoType, ProjectionQuery<T> query) Projects a DTO type from the given entity type using the provided query.
-
Constructor Details
-
JpaProjectionExecutor
public JpaProjectionExecutor(jakarta.persistence.EntityManager entityManager, CriteriaProjectionBuilder projectionBuilder, ProjectionMetadataRegistry metadataRegistry) Constructs a new JpaProjectionExecutor with the given parameters.- Parameters:
entityManager
- the EntityManager to use for executing queriesprojectionBuilder
- the CriteriaProjectionBuilder to build projection expressionsmetadataRegistry
- the ProjectionMetadataRegistry to access compile-time generated metadata
-
-
Method Details
-
project
public <T,D> ProjectionResult<D> project(Class<T> entityType, Class<D> dtoType, ProjectionQuery<T> query) Projects a DTO type from the given entity type using the provided query. This method constructs a JPA Criteria query to select the DTO and its ID, applying any filters and pagination specified in the query.- Specified by:
project
in interfaceProjectionExecutor
- Type Parameters:
T
- entity typeD
- dto type- Parameters:
entityType
- the entity classdtoType
- the DTO class to project toquery
- the projection query definition- Returns:
- result containing the projected DTOs
-