简体   繁体   中英

Spring JPA : If length of rows achieves to value of greater than max List length what does happens?

If length of database rows achieves to value of greater than max java.util.List length and i try to get all data what does happens?

public interface StudentRepository extends CrudRepository<Student, Long> {
    @Override
    List<Log> findAll();
}

If you are talking about Java ArrayList, the max size can be 2,147,483,647. So I am pretty sure it is big enough to handle any big tables.

But problem is not that. What you are talking about finding all rows of a database table in a single call is simply a bad design. If you try to fetch all the rows at once & table say have 100,000 entries, you will run out of JVM memory in most cases. You are loading the rows in JVM after all. People generally use pagination to handle this kind of scenario.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM