Class SimpleHibernateBatchOperationManager5

  • All Implemented Interfaces:
    BatchOperationManager

    @Transactional
    public class SimpleHibernateBatchOperationManager5
    extends Object
    implements BatchOperationManager
    Provides methods for performing batch operations in a series of independent transactions.

    WARNING: Methods in this batching manager may clear the current session! It was added as a successor of SimpleHibernateBatchOperationManager because of Hibernate 2 removal.

    Since:
    7.16.0
    • Constructor Detail

      • SimpleHibernateBatchOperationManager5

        public SimpleHibernateBatchOperationManager5​(HibernateSessionManager5 sessionManager)
    • Method Detail

      • performAsBatch

        @Deprecated
        public <I,​O> Iterable<O> performAsBatch​(Iterable<I> input,
                                                      int batchSize,
                                                      int expectedTotal,
                                                      com.google.common.base.Function<I,​O> task)
        Deprecated.
        Executes a task for each item in a collection in batches with configurable batch size

        WARNING: This method will clear the current session! The session clearing will discard any unflushed or uncommitted changes made higher in the stack. Calls to this method should generally be done in a separate thread or otherwise outside the scope of a request.

        Specified by:
        performAsBatch in interface BatchOperationManager
        Type Parameters:
        I - input type
        O - output type
        Parameters:
        input - the items to process
        batchSize - the size of the batch
        expectedTotal - the expected number of items to process
        task - a function to process the items
        Returns:
        list of task outputs of specified type
        Since:
        7.16.0 added as deprecated because the interface still requires it.
      • applyInBatches

        public <I,​O> Iterable<O> applyInBatches​(Iterable<I> input,
                                                      int batchSize,
                                                      int expectedTotal,
                                                      Function<I,​O> task)
        Description copied from interface: BatchOperationManager
        Executes a task for each item in a collection in batches with configurable batch size
        Specified by:
        applyInBatches in interface BatchOperationManager
        Type Parameters:
        I - input type
        O - output type
        Parameters:
        input - the items to process
        batchSize - the size of the batch
        expectedTotal - the expected number of items to process
        task - a function to process the items
        Returns:
        list of task outputs of specified type
      • performAsBatch

        @Deprecated
        public <I,​O> Iterable<O> performAsBatch​(Iterable<I> input,
                                                      int expectedTotal,
                                                      com.google.common.base.Function<I,​O> task)
        Deprecated.
        Executes a task for each item in a collection in batches

        WARNING: This method will clear the current session! The session clearing will discard any unflushed or uncommitted changes made higher in the stack. Calls to this method should generally be done in a separate thread or otherwise outside the scope of a request.

        Specified by:
        performAsBatch in interface BatchOperationManager
        Type Parameters:
        I - input type
        O - output type
        Parameters:
        input - the items to process
        expectedTotal - the expected number of items to process
        task - a function to process the items
        Returns:
        list of task outputs of specified type
      • applyInBatches

        public <I,​O> Iterable<O> applyInBatches​(Iterable<I> input,
                                                      int expectedTotal,
                                                      Function<I,​O> task)
        Description copied from interface: BatchOperationManager
        Executes a task for each item in a collection in batches
        Specified by:
        applyInBatches in interface BatchOperationManager
        Type Parameters:
        I - input type
        O - output type
        Parameters:
        input - the items to process
        expectedTotal - the expected number of items to process
        task - a function to process the items
        Returns:
        list of task outputs of specified type
      • performInChunks

        @Deprecated
        public <I,​O> Iterable<O> performInChunks​(Iterable<I> input,
                                                       int chunkSize,
                                                       int sizeToCollect,
                                                       com.google.common.base.Function<List<I>,​@NonNull List<O>> task)
        Deprecated.
        Processes a collection of items in chunks until a given number of processed items is reached, the processed items are then returned.

        This method does NOT perform batch operations in independent transactions. To do so, transactions will need to be handled by the provided processing function. Alternatively, consider using BatchOperationManager.applyInBatches(Iterable, int, Function)

        Specified by:
        performInChunks in interface BatchOperationManager
        Parameters:
        input - the items to process
        chunkSize - the size of the batch
        sizeToCollect - the number of processed items to return
        task - a function to process the items
        Returns:
        A list of processed items
      • applyInChunks

        public <I,​O> Iterable<O> applyInChunks​(Iterable<I> input,
                                                     int chunkSize,
                                                     int sizeToCollect,
                                                     Function<List<I>,​@NonNull List<O>> task)
        Description copied from interface: BatchOperationManager
        Processes a collection of items in chunks until a given number of processed items is reached, the processed items are then returned.
        Specified by:
        applyInChunks in interface BatchOperationManager
        Parameters:
        input - the items to process
        chunkSize - the size of the batch
        sizeToCollect - the number of processed items to return
        task - a function to process the items
        Returns:
        A list of processed items