I need to use HibernateCursorItemReader in a Job due to size of the Resultset, but I can't make it work with an EntityGraph to fetch some relationships eagerly. I'm using QueryProvider.
Without any EntityGraph no join occurs, and the reader works properly, but during batch processing Hibernate execute numerous SQL queries to fetch data lazily. This results in a very slow processing.
With the query hint to fetch it, the task freezes at this point of Loader.class
:
ResultSet rs = session.getJdbcCoordinator().getResultSetReturn().extract( st );
The code above is called during doOpen
method of HibernateCursorItemReader, before the very first item. No errors, no stack trace, just nothing for several minutes, until I stop JVM.
I'm using HibernatePagingItemReader for now, with the same QueryProvider and hint to fetch data eagerly. But pagination is not efficient when fetching entities with collections, JVM get often memory lacks.
Sorry for the lack of example codes, but what I have is the default configuration and implementations of mentioned classes, nothing specific to show about. I think cursor reader is the solution, but how can it work with EntityGraph?
EDIT 1
Seems to be nothing wrong with EntityGraph and HibernateCursorItemReader together. Being patient and waiting more time, the processing started. It is just slowly than usual, but hibernate's cursor reader works the same way as the pagination reader, fetching all entity graph.
Seems to be nothing wrong with EntityGraph and HibernateCursorItemReader together. Being patient and waiting more time, the processing started. It is just slowly than usual, but hibernate's cursor reader works the same way as the pagination reader, fetching all entity graph.