Since Hibernate 5.2, we are able to use the stream() method instead of scroll() if we want to fetch large amount of data.
However, when using scroll() with ScrollableResults we are able to a hook into the retrieval process and to free memory up by either evicting the object from the persistent context after processing it and/or clearing the entire session every now and then.
My questions:
- Now, if we use the
stream()method, what happens behind the scenes? - Is it possible to evict object from the persistent context?
- Is the session cleared periodically?
- How is optimal memory consumption achieved?
- Is is possible to use e.g. StatelessSession?
- Also, if we have set
hibernate.jdbc.fetch_sizeto some number (e.g. 1000) at JPA properties, then how is this combined well with scrollable results?