You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue seems to have started with Spring Boot 2.6.3.
When a JpaRepository interface defines a query created by a method name that returns a projection the application will fail to start with the error below.
Failed to create query for method public abstract com.bug.demo.bugdemo.AgeProjection com.bug.demo.bugdemo.PersonRepository.findByFirstNameIgnoreCase(java.lang.String)! null; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract com.bug.demo.bugdemo.AgeProjection com.bug.demo.bugdemo.PersonRepository.findByFirstNameIgnoreCase(java.lang.String)! null
Issue seems to have started with Spring Boot 2.6.3.
When a JpaRepository interface defines a query created by a method name that returns a projection the application will fail to start with the error below.
Failed to create query for method public abstract com.bug.demo.bugdemo.AgeProjection com.bug.demo.bugdemo.PersonRepository.findByFirstNameIgnoreCase(java.lang.String)! null; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract com.bug.demo.bugdemo.AgeProjection com.bug.demo.bugdemo.PersonRepository.findByFirstNameIgnoreCase(java.lang.String)! null
Repository:
`public interface PersonRepository extends JpaRepository<PersonEntity, Integer> {
}`
Adding a @query annotation to the method with the JPQL query below will successfully execute and return the projection.
`public interface PersonRepository extends JpaRepository<PersonEntity, Integer> {
@query("select p from PersonEntity p where p.firstName = ?1")
Optional findByFirstName(String firstName);
}`
Entity class:
`@Entity
public class PersonEntity {
@id
private Integer id;
// getters/setters
}`
Age Projection:
public interface AgeProjection { Integer getAge(); }
The text was updated successfully, but these errors were encountered: