Class JpaProjectionExecutor

java.lang.Object
nl.datasteel.crudcraft.projection.impl.jpa.JpaProjectionExecutor
All Implemented Interfaces:
ProjectionExecutor

public class JpaProjectionExecutor extends Object implements ProjectionExecutor
JPA-based implementation of ProjectionExecutor using Criteria API.
  • 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 queries
      projectionBuilder - the CriteriaProjectionBuilder to build projection expressions
      metadataRegistry - 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 interface ProjectionExecutor
      Type Parameters:
      T - entity type
      D - dto type
      Parameters:
      entityType - the entity class
      dtoType - the DTO class to project to
      query - the projection query definition
      Returns:
      result containing the projected DTOs