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 Type
    Method
    Description
    <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 entity
      D - the type of the DTO
      Parameters:
      cb - the CriteriaBuilder to use for constructing the query
      entityType - the type of the entity to project from
      dtoType - the type of the DTO to project into
      query - 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 selections
      from - the 'From' object representing the root entity
      dtoType - the type of the DTO to project into
      Returns:
      a Selection that constructs the DTO from the entity paths