Class ProjectionAutoConfiguration
java.lang.Object
nl.datasteel.crudcraft.projection.config.ProjectionAutoConfiguration
@AutoConfiguration
@EnableConfigurationProperties(ProjectionProperties.class)
public class ProjectionAutoConfiguration
extends Object
Spring Boot auto configuration for projection support.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionProvides a CriteriaProjectionBuilder that uses ProjectionMetadataRegistry to access compile-time generated metadata.jpaProjectionExecutorProvider
(jakarta.persistence.EntityManager entityManager, CriteriaProjectionBuilder criteriaBuilder, ProjectionMetadataRegistry registry, ProjectionProperties properties) Provides a JpaProjectionExecutorProvider that uses JPA Criteria API for projections.projectionExecutor
(List<ProjectionExecutorProvider> providers) Provides a ProjectionExecutor that routes to the appropriate executor based on the available ProjectionExecutorProviders.Provides a ProjectionMetadataRegistry that can be used to access compile-time generated metadata for projections.Provides a QuerydslProjectionBuilder that uses ProjectionMetadataRegistry to access compile-time generated metadata.querydslProjectionExecutorProvider
(com.querydsl.jpa.impl.JPAQueryFactory queryFactory, jakarta.persistence.EntityManager entityManager, QuerydslProjectionBuilder querydslBuilder, ProjectionMetadataRegistry registry, ProjectionProperties properties) Provides a QuerydslProjectionExecutorProvider that uses QueryDSL for projections.
-
Constructor Details
-
ProjectionAutoConfiguration
public ProjectionAutoConfiguration()
-
-
Method Details
-
projectionMetadataRegistry
Provides a ProjectionMetadataRegistry that can be used to access compile-time generated metadata for projections. If the GeneratedProjectionMetadataRegistry class is not found, it falls back to a SimpleProjectionMetadataRegistry.- Returns:
- the ProjectionMetadataRegistry instance
-
criteriaProjectionBuilder
@Bean public CriteriaProjectionBuilder criteriaProjectionBuilder(ProjectionMetadataRegistry registry) Provides a CriteriaProjectionBuilder that uses ProjectionMetadataRegistry to access compile-time generated metadata. This builder can be used to construct JPA Criteria API expressions for projections.- Parameters:
registry
- the ProjectionMetadataRegistry to use for accessing metadata- Returns:
- the CriteriaProjectionBuilder instance
-
querydslProjectionBuilder
@Bean public QuerydslProjectionBuilder querydslProjectionBuilder(ProjectionMetadataRegistry registry) Provides a QuerydslProjectionBuilder that uses ProjectionMetadataRegistry to access compile-time generated metadata. This builder can be used to construct QueryDSL expressions for projections.- Parameters:
registry
- the ProjectionMetadataRegistry to use for accessing metadata- Returns:
- the QuerydslProjectionBuilder instance
-
jpaProjectionExecutorProvider
@Bean @ConditionalOnBean(jakarta.persistence.EntityManager.class) @ConditionalOnProperty(prefix="crudcraft.projection", name="engine", havingValue="CRITERIA", matchIfMissing=true) public ProjectionExecutorProvider jpaProjectionExecutorProvider(jakarta.persistence.EntityManager entityManager, CriteriaProjectionBuilder criteriaBuilder, ProjectionMetadataRegistry registry, ProjectionProperties properties) Provides a JpaProjectionExecutorProvider that uses JPA Criteria API for projections. This provider is only created if an EntityManager bean is available.- Parameters:
entityManager
- the EntityManager to use for executing queriescriteriaBuilder
- the CriteriaProjectionBuilder to build projection expressionsregistry
- the ProjectionMetadataRegistry to access compile-time generated metadataproperties
- the ProjectionProperties to configure the projection engine- Returns:
- the JpaProjectionExecutorProvider instance
-
querydslProjectionExecutorProvider
@Bean @ConditionalOnBean(com.querydsl.jpa.impl.JPAQueryFactory.class) @ConditionalOnProperty(prefix="crudcraft.projection", name="engine", havingValue="QUERYDSL") public ProjectionExecutorProvider querydslProjectionExecutorProvider(com.querydsl.jpa.impl.JPAQueryFactory queryFactory, jakarta.persistence.EntityManager entityManager, QuerydslProjectionBuilder querydslBuilder, ProjectionMetadataRegistry registry, ProjectionProperties properties) Provides a QuerydslProjectionExecutorProvider that uses QueryDSL for projections. This provider is only created if a JPAQueryFactory bean is available.- Parameters:
queryFactory
- the JPAQueryFactory to use for executing queriesentityManager
- the EntityManager to access the JPA metamodelquerydslBuilder
- the QuerydslProjectionBuilder to build projection expressionsregistry
- the ProjectionMetadataRegistry to access compile-time generated metadataproperties
- the ProjectionProperties to configure the projection engine- Returns:
- the QuerydslProjectionExecutorProvider instance
-
projectionExecutor
@Bean @ConditionalOnBean(ProjectionExecutorProvider.class) public ProjectionExecutor projectionExecutor(List<ProjectionExecutorProvider> providers) Provides a ProjectionExecutor that routes to the appropriate executor based on the available ProjectionExecutorProviders. If only one provider is available, it returns that executor directly. If multiple providers are available, it returns a RoutingProjectionExecutor that delegates to the appropriate provider based on the query type.- Parameters:
providers
- the list of ProjectionExecutorProviders- Returns:
- the ProjectionExecutor instance
-