Class HibernateNonFlushingSessionWrapper
java.lang.Object
com.atlassian.confluence.impl.hibernate.HibernateNonFlushingSessionWrapper
- All Implemented Interfaces:
NonFlushingSessionWrapper
Wrapper around
HibernateSessionManager5
- Since:
- 8.5.22
-
Constructor Summary
ConstructorsConstructorDescriptionHibernateNonFlushingSessionWrapper
(HibernateSessionManager5 hibernateSessionManager) -
Method Summary
Modifier and TypeMethodDescriptionint
executeThenClearSessionWithoutCommitOrFlush
(int batchSize, int expectedTotal, Function<Integer, Integer> taskExecutor) Execute tasks in batches, re-using the existing transaction rather than nesting transactions.
-
Constructor Details
-
HibernateNonFlushingSessionWrapper
-
-
Method Details
-
executeThenClearSessionWithoutCommitOrFlush
public int executeThenClearSessionWithoutCommitOrFlush(int batchSize, int expectedTotal, Function<Integer, Integer> taskExecutor) Execute tasks in batches, re-using the existing transaction rather than nesting transactions. WARNING: the session clearing will discard any unflushed or uncommitted changes made higher in the stack. Use this method only for the operations that do not write to database. Also, the existing transaction will not be committed in this method.- Specified by:
executeThenClearSessionWithoutCommitOrFlush
in interfaceNonFlushingSessionWrapper
- Parameters:
batchSize
- the positive number of tasks to execute in a batch, before any hibernate flush or clears.expectedTotal
- the positive total number of tasks to be executed.taskExecutor
- the task executor. The taskExecutor should accept the batchSize to execute, and return how many tasks have been successfully executed.- Returns:
- the number of tasks which were executed successfully.
-