No property found for type... custom Spring Data repository

The problem here is that you are creating FilterRepositoryImpl but you are using it in UserRepository. You need to create UserRepositoryImpl to make this work.

Read this doc for more detail

Basically

public interface UserRepositoryCustom {
    List<User> filterBy(String role);
}

public class UserRepositoryImpl implements UserRepositoryCustom {
...
}

public interface UserRepository extends JpaRepository<User, String>, UserRepositoryCustom {
...
}

Spring Data 2.x update
This answer was written for Spring 1.x. As Matt Forsythe pointed out, the naming expectations changed with Spring Data 2.0. The implementation changed from the-final-repository-interface-name-with-an-additional-Impl-suffix to the-custom-interface-name-with-an-additional-Impl-suffix.

So in this case, the name of the implementation would be: UserRepositoryCustomImpl.


Is it a must that the customMethod() in the CustomRepository can only have parameters defined that are either

1.Entity class name - customMethod(User user),

2.Entity class attributes - customMethod(String firstName), here firstName is an attribute of User Entity class.

Can I not have something like customMethod(CustomCriteria criteria), the criteria class contain the various attributes that are used to construct a dynamic query.

e.g. getStatusByCriteria(CustomCriteria criteria), CustomCriteria is a simple pojo annotated with @Component so that spring identifies it.

When I tried this I get an error:

org.springframework.data.mapping.PropertyReferenceException: No property criteria found for type UserRepository!


Another way this error can happen if the impl class for FilterRepositoryCustom isn't picked up in your spring configuration:

@EnableJpaRepositories(basePackageClasses = {RepoPackageMarker.class, FilterRepositoryCustomImpl.class})