pramoth / specification-with-projection

Support projections with JpaSpecificationExecutor.findAll(Specification,Pageable) for Spring Data JPA
MIT License
164 stars 56 forks source link

findById throws org.springframework.dao.InvalidDataAccessApiUsageException "only except projection" #23

Open barryspearce opened 3 years ago

barryspearce commented 3 years ago

Upgrading from 2.0.1 to 2.0.2 caused significant breaking issues across my repositories:

I had to remove every single one of my methods from every single repository that I had included:

<T> Optional<T> findById(Long id, Class<T> type);

However, whereas the Spring implementation works flawlessly, the JpaSpecificationExecutorWithProjection version throws an exception every single time across multiple projects:

org.springframework.dao.InvalidDataAccessApiUsageException: only except projection; nested exception is java.lang.IllegalArgumentException: only except projection

Coupled with the introduction of forcing an Id field (another issue). This makes 2.0.2 unusable

Why has findById been implemented when Spring itself provides perfectly adequate accurate implementation as standard? Duplication of spring code would be unwise. This appears to be feature creep beyond providing Execution of specifications with projections.