[JAVA] No property list found for type because it is a non-named query of Spring Data JPA

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

No property list found for type because it is a non-named query of Spring Data JPA
Spring Data JPA: Write a query in Pure SQL in @Query of Repository
Sample code for search using QBE (Query by Example) of Spring Data JPA
[Spring Data JPA] Custom ID is assigned in a unique sequence at the time of registration.
A list of rawValues for UITextContentType.
What is it? ~ 3 types of "no" ~