I’ve seen some repositories return `Iterable<T&...
# spring
j
I’ve seen some repositories return
Iterable<T>
and others
List<T>
. I believe repositories return a
List
of entites so why would anyone specify return type of
Iterable
? e.g. https://github.com/spring-guides/tut-spring-boot-kotlin/blob/main/src/main/kotlin/com/example/blog/Repositories.kt#L7
e
Generally and practically speaking,
List
and other
Collection
types require the entire result set to be loaded into memory. An
Iterable
doesn't necessarily enforce that. Whether you actually get any mileage out of that distinction is up to Spring's implementation. IIRC you can also return
Stream
as well.