Ten years later, but I discovered that elements are added to executions list if the queryCache is enabled
For hibernate version lower than 3.5.3
In org.hibernate.engine.ActionQueue
Code:
public void execute(Executable executable) {
final boolean lockQueryCache = session.getFactory().getSettings().isQueryCacheEnabled();
if ( executable.hasAfterTransactionCompletion() || lockQueryCache ) {
executions.add( executable );
}
if ( lockQueryCache ) {
session.getFactory()
.getUpdateTimestampsCache()
.preinvalidate( executable.getPropertySpaces() );
}
executable.execute();
}
and at the Tx end, the transaction tries to be sync to the cache, which is why executions is kept around.
So, I'd recommend to wrap the processor and commit the transaction every X amount of records processed.
Another, very very DIRTY solution is to execute this after your clear(), which
iterates through the executions and syncs them with cache. so this will ONLY work if updated tables != cached tables, and worse, it may break in future hibernate versions. Better to commit periodically instead :)
((SessionImpl) getSession()).getActionQueue().afterTransactionCompletion(true);
...
versiosn higher than 3.5.3 modified the algorithm, so I can't say if it has a bug or not, I'll have to test.