Reputation: 1413
My UserRepository
:
public interface UserRepository extends CrudRepository<User, Integer> {
List<User> findAll(List<Integer> ids);
}
Error:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type User
Can some one tell me how to get list of User
objects based on List of Id's.
This is working
@Query(" select new User(id,x,y,z) from User b where b.id in ?1 ")
List<User> findById(List<Integer> id);
Upvotes: 1
Views: 23283
Reputation: 2009
Firstly, I would rename the repository to UserRepository
, because having 2 User
classes is confusing.
findAll()
, by definition, is meant to get all the models with no criteria. You should add a method named
findByIdIn(Collection<Integer> ids)
Use List<User> findAll(Iterable<Integer> ids)
or List<User> findByIdIn(List<Integer> ids)
Upvotes: 6