Spring Data JPA - "No Property Found for Type" Exception Spring Data JPA - "No Property Found for Type" Exception java java

Spring Data JPA - "No Property Found for Type" Exception


I ran into this same issue and found the solution here: https://dzone.com/articles/persistence-layer-spring-data

I had renamed an entity property. But with Springs Automatic Custom Queries there was an interface defined for the old property name.

public interface IFooDAO extends JpaRepository< Foo, Long >{     Foo findByOldPropName( final String name );}

The error indicated that it could no longer find OldPropName and threw the exception.

To quote the article on DZone:

When Spring Data creates a new Repository implementation, it analyzes all the methods defined by the interfaces and tries to automaticallygenerate queries from the method name. While this has limitations, itis a very powerful and elegant way of defining new custom accessmethods with very little effort. For example, if the managed entityhas a name field (and the Java Bean standard getter and setter forthat field), defining the findByName method in the DAO interface willautomatically generate the correct query:

public interface IFooDAO extends JpaRepository< Foo, Long >{     Foo findByName( final String name );}

This is a relatively simple example; a much larger set of keywords is supported by query creation mechanism.

In the case that the parser cannot match the property with the domain object field, the following exception is thrown:

java.lang.IllegalArgumentException: No property nam found for type class org.rest.model.Foo


Your naming is not correct.

As per the documentation, if your repository is UserBoardRepository, the implementation of your custom repository should be name as UserBoardRepositoryImpl, here you named it as BoardServiceImpl, that's why it throws the exception.


Fixed, While using CrudRepository of Spring , we have to append the propertyname correctly after findBy otherwise it will give you exception "No Property Found for Type”

I was getting this exception as. because property name and method name were not in sync.

I have used below code for DB Access.

public interface UserDao extends CrudRepository<User, Long> {    User findByUsername(String username);

and my Domain User has property.

@Entitypublic class User implements UserDetails {    /**     *      */    private static final long serialVersionUID = 1L;    @Id    @GeneratedValue(strategy = GenerationType.AUTO)    @Column(name = "userId", nullable = false, updatable = false)    private Long userId;    private String username;