Interface SessionUtils

  • All Known Implementing Classes:
    DefaultSessionUtils, MockSessionUtils

    public interface SessionUtils
    Utility functions for dealing with Hibernate session and transactions. These functions were added to this interface to help make them accessible to bundles running in the OSGi container without having to deal with class-path issues related to Spring & Hibernate.
    Author:
    jwhite
    • Method Detail

      • withTransaction

        <V> V withTransaction​(java.util.function.Supplier<V> supplier)
        Invoked the given supplier within the context of a transaction.
        Type Parameters:
        V - type returned by the supplier
        Parameters:
        supplier - supplier to invoke
        Returns:
        value returned by the supplier
      • withTransaction

        default void withTransaction​(Runnable runnable)
      • withReadOnlyTransaction

        <V> V withReadOnlyTransaction​(java.util.function.Supplier<V> supplier)
        Invokes the given supplier within the context of a read-only transaction.
        Type Parameters:
        V - type returned by the supplier
        Parameters:
        supplier - supplier to invoke
        Returns:
        value returned by the supplier
      • withReadOnlyTransaction

        default void withReadOnlyTransaction​(Runnable runnable)
      • withManualFlush

        <V> V withManualFlush​(java.util.function.Supplier<V> supplier)
        Converts the flush mode for the current session factory to MANUAL for the duration of the call to the given supplier. The flush mode is reverted to it's previous value after the call.
        Type Parameters:
        V - type returned by the supplier
        Parameters:
        supplier - supplier to invoke
        Returns:
        value returned by the supplier
      • withManualFlush

        default void withManualFlush​(Runnable runnable)