ARTICLE AD BOX
I’m trying to integrate Blaze Persistence with Spring Boot 3.5.5 (Java 21, Hibernate 6.2). This is my first attempt to use Blaze in one of my projects, and I’m running into an incompatibility between Spring Data JPA and Blaze Persistence’s EntityViewSpecificationExecutor when calling findOne.
Problem :
When I call findOne, Spring Data JPA expects to return an Optional<T>, but Blaze Persistence expects to return an Entity View. As a result, I get a ClassCastException:
java.lang.ClassCastException: class java.util.Optional cannot be cast to class xx.xxx.xxx.prestation.views.PrestationStatusView
(java.util.Optional is in module java.base of loader 'bootstrap';
xx.xxx.xxx.prestation.views.PrestationStatusView is in unnamed module of loader 'app')
@Transactional(readOnly = true) public interface PrestationStatusRepository extends EntityViewRepository<PrestationStatusView, Long>, EntityViewSpecificationExecutor<PrestationStatusView, Prestation> { } Dependencies : <!-- Core dependencies --> <dependency> <groupId>com.blazebit</groupId> <artifactId>blaze-persistence-integration-hibernate-6.2</artifactId> </dependency> <!-- Spring integration dependencies --> <dependency> <groupId>com.blazebit</groupId> <artifactId>blaze-persistence-integration-entity-view-spring-6.0</artifactId> </dependency> <dependency> <groupId>com.blazebit</groupId> <artifactId>blaze-persistence-integration-spring-data-3.4</artifactId> <version>${blaze-persistence.version}</version> </dependency> <dependency> <groupId>com.blazebit</groupId> <artifactId>blaze-persistence-integration-spring-data-base-4.0</artifactId> </dependency>Question
How can I properly configure Blaze Persistence with Spring Data JPA so that findOne works correctly with EntityViewSpecificationExecutor?
Should I avoid using findOne directly on the repository?
Is there a specific Blaze Persistence API I should call instead?
Or is this a known incompatibility between Spring Data JPA’s Optional return type and Blaze’s Entity View handling?
