Spring Data JpaRepository findAll(Iterable<ID> ids) + findAll(Sort sort)
18,408
Just declare a query method like this:
public interface UserRepository extends Repository<User, Integer> {
Iterable<User> findByIdIn(Collection<Integer> ids, Sort sort);
}
Related videos on Youtube
Comments
-
Channa over 1 year
With Spring Data JpaRepository is there any capability to get select collection of given Id with some sorting. That mean I need to make enable following query. I have found some solution apply with @NamedQuery but I can't make enable it because I am using Spring-data-jap 1.4.2.RELEASE. Thanks.
public Iterable<User> findAll(Iterable<Integer> userIds) { Sort sort = new Sort(Direction.ASC, "name"); Iterable<User> users = userRepository.findAll(userIds, sort); return users; }