As shown below, if you inadvertently specify JPQL for `` `name``` even though it is not a named query, a seemingly mysterious run-time error will occur.
@Repository
public interface SampleRepository extends JpaRepository<Sample, Long> {
@Query(name = "select s from Sample s")
List<Sample> list();
}
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property list found for type Sample!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
When I calm down, it's just an error that there is no named query with such a name, but I was rushed to get a run-time error even though I intended to specify JPQL correctly, so I'll leave a note.
To be correct, specify JPQL in value
.
@Query("select s from Sample s")
List<Sample> list();
Recommended Posts