What is difference between setMaxResults
and setFetchSize
in org.hibernate.Query? I just can no get it =)
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
setMaxResults
limits the number of results the query will ever get.setFetchSize
tells the jdbc driver how many rows to return in one chunk, for large queries. Say you want 1000 rows. If you set the fetch size to 100, the db will return 100, then another 100 when you want more, and so on.setFetchSize
will do nothing if your driver does not support it.setMaxResults
is the same asLIMIT
in SQL- you are setting the maximum number of rows you want returned. This is a very common use case of course.setFetchSize
is about optimization, which can change how Hibernate goes about sending the results to the caller (example: buffered, in different size chunks).setFetchSize
is NOT implemented by all database drivers.For example, if the table has 100 records, then
will only fetch 25 records out of 100 records, and
will fetch 20 records at each time until it reads all 100 records from the table.