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 Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void withManualFlush​(java.lang.Runnable runnable)  
      <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.
      default void withReadOnlyTransaction​(java.lang.Runnable runnable)  
      <V> V withReadOnlyTransaction​(java.util.function.Supplier<V> supplier)
      Invokes the given supplier within the context of a read-only transaction.
      default void withTransaction​(java.lang.Runnable runnable)  
      <V> V withTransaction​(java.util.function.Supplier<V> supplier)
      Invoked the given supplier within the context of a transaction.
    • 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​(java.lang.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​(java.lang.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​(java.lang.Runnable runnable)