I have noticed something weird in Spring data for mongo :
MongoRepository
extends CrudRepository
and the findAll()
returns an Iterable
which it's ok with the count()
method as it returns a long
.
class CrudRepository {
...
Iterable<T> findAll();
long count();
}
In mongo MongoRepository
the findAll()
method returs a List
:
class MongoRepository extends CrudRepository {
...
@Override
List<T> findAll();
}
But a List#size()
returns an int
and the MongoRepository#count()
method stay returning a long.
What happens when the collection exceed Integer.MAX_VALUE
!? Could we still call List<T> findAll()
?