Class HibernateNonFlushingSessionWrapper

java.lang.Object
com.atlassian.confluence.impl.hibernate.HibernateNonFlushingSessionWrapper
All Implemented Interfaces:
NonFlushingSessionWrapper

public class HibernateNonFlushingSessionWrapper extends Object implements NonFlushingSessionWrapper
Since:
8.5.22
  • Constructor Details

    • HibernateNonFlushingSessionWrapper

      public HibernateNonFlushingSessionWrapper(HibernateSessionManager5 hibernateSessionManager)
  • 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 interface NonFlushingSessionWrapper
      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.