Announcing ListCrudRepository & Friends for Spring Data 3.0
The Spring Data CrudRepository
has various methods that return multiple instances of the entity managed by the repository. It does so by using Iterable
and not List
, as one might expect. In many cases, that is of no consequence, since you typically want to iterate over the result anyway. However, you might occasionally prefer a List
. In these cases, Iterable
is annoying.
I will write more about why that choice was made in the first place and how you can deal with it as long as you are on Spring Data 2.x. However, let me get the good news out first:
Repositories returning Lists
Spring Data 3.0.0 now offers a ListCrudRepository
in the latest snapshot releases, which returns a List
where CrudRepository
returns an Iterable
…