Spring Data JPA - "No Property Found for Type" Exception
This exception is usually thrown when you are trying to access a property that does not exist in the entity class you are querying.
For example, if you have the following query:
SELECT p FROM Person p WHERE p.age > 20
And you do not have an age
property in the Person
entity class, you will get this exception.
To fix this, make sure that you are accessing properties that exist in the entity class. If you are trying to access a property that is not directly mapped to a column in the database, you will need to use a @Transient
annotation to specify that the property is not persistent.
If you are using Spring Data JPA, you can also use the @Query
annotation to write a custom JPQL or native SQL query that specifies the columns you want to select. This can be useful if you want to select only a subset of the properties in the entity class.