The projection-spring-data module provides Spring Boot auto-configuration for ProjectionQuery. Use the processor alongside Spring Data repositories; this module does not add methods to JpaRepository.
Add the Spring dependency and configure JPA, including your datasource, JDBC driver, and entities. Auto-configuration requires an EntityManager and an EntityManagerFactory.
The following components can be managed by Spring:
Note: Each default bean is registered only when a bean of the same type is missing (
@ConditionalOnMissingBean). You can supply your own bean where customization is needed. The debug processor’s fallback mode executes a query against the database.
Example:
@Service
public class MyService {
private final ProjectionProcessor projectionProcessor;
private final ProjectionProcessorDebug projectionProcessorDebug;
private final ProjectionFilterOperatorProvider filterProvider;
private final ProjectionSelectOperatorProvider selectOperatorProvider;
public MyService(
ProjectionProcessor projectionProcessor,
ProjectionProcessorDebug projectionProcessorDebug,
ProjectionFilterOperatorProvider filterProvider,
ProjectionSelectOperatorProvider selectOperatorProvider
){
this.projectionProcessor = projectionProcessor;
this.projectionProcessorDebug = projectionProcessorDebug;
this.filterProvider = filterProvider;
this.selectOperatorProvider = selectOperatorProvider;
}
}