Class SpringHibernateTransactionOperations

  • All Implemented Interfaces:
    TransactionOperations<java.sql.Connection>

    @Requires(classes=org.springframework.orm.hibernate5.HibernateTransactionManager.class)
    @EachBean(org.springframework.orm.hibernate5.HibernateTransactionManager.class)
    @Internal
    @Replaces(SpringJdbcTransactionOperations.class)
    public class SpringHibernateTransactionOperations
    extends java.lang.Object
    implements TransactionOperations<java.sql.Connection>
    Adds Spring Transaction management capability to Micronaut Data.
    Since:
    1.0.0
    Author:
    graemerocher
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SpringHibernateTransactionOperations​(org.springframework.orm.hibernate5.HibernateTransactionManager hibernateTransactionManager)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <R> R execute​(TransactionDefinition definition, TransactionCallback<java.sql.Connection,​R> callback)
      Execute a transaction within the context of the function.
      <R> R executeRead​(TransactionCallback<java.sql.Connection,​R> callback)
      Execute a read-only transaction within the context of the function.
      <R> R executeWrite​(TransactionCallback<java.sql.Connection,​R> callback)
      Execute a default transaction within the context of the function.
      java.sql.Connection getConnection()
      Obtains the connection for the current transaction.
      boolean hasConnection()
      Check if the connection exists.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SpringHibernateTransactionOperations

        protected SpringHibernateTransactionOperations​(org.springframework.orm.hibernate5.HibernateTransactionManager hibernateTransactionManager)
        Default constructor.
        Parameters:
        hibernateTransactionManager - The hibernate transaction manager.
    • Method Detail

      • executeRead

        public <R> R executeRead​(@NonNull
                                 TransactionCallback<java.sql.Connection,​R> callback)
        Description copied from interface: TransactionOperations
        Execute a read-only transaction within the context of the function.
        Specified by:
        executeRead in interface TransactionOperations<java.sql.Connection>
        Type Parameters:
        R - The result
        Parameters:
        callback - The call back
        Returns:
        The result
      • executeWrite

        public <R> R executeWrite​(@NonNull
                                  TransactionCallback<java.sql.Connection,​R> callback)
        Description copied from interface: TransactionOperations
        Execute a default transaction within the context of the function.
        Specified by:
        executeWrite in interface TransactionOperations<java.sql.Connection>
        Type Parameters:
        R - The result
        Parameters:
        callback - The call back
        Returns:
        The result
      • getConnection

        @NonNull
        public java.sql.Connection getConnection()
        Description copied from interface: TransactionOperations
        Obtains the connection for the current transaction.
        Specified by:
        getConnection in interface TransactionOperations<java.sql.Connection>
        Returns:
        The connection
      • execute

        public <R> R execute​(@NonNull
                             TransactionDefinition definition,
                             @NonNull
                             TransactionCallback<java.sql.Connection,​R> callback)
        Description copied from interface: TransactionOperations
        Execute a transaction within the context of the function.
        Specified by:
        execute in interface TransactionOperations<java.sql.Connection>
        Type Parameters:
        R - The result
        Parameters:
        definition - The transaction definition
        callback - The call back
        Returns:
        The result