Class Transaction


  • @Technical
    @Bean
    public class Transaction
    extends Object
    A transaction. All processes it performs will be in charge by the JPA transaction manager.
    Author:
    mmoquillon
    • Constructor Detail

      • Transaction

        public Transaction()
    • Method Detail

      • getTransaction

        public static Transaction getTransaction()
        Gets a transaction instance in order to perform some transactional tasks.
        Returns:
        a transaction.
      • performInOne

        public static <V> V performInOne​(Process<V> process)
        Performs in a single transaction the specified process.
        Type Parameters:
        V - the type of the return value.
        Parameters:
        process - the process to execute in a transaction.
        Returns:
        the result of the process.
      • performInNew

        public static <V> V performInNew​(Process<V> process)
        Performs in a new transaction the specified process.
        Type Parameters:
        V - the type of the return value.
        Parameters:
        process - the process to execute in a transaction.
        Returns:
        the result of the process.
      • isTransactionActive

        public static boolean isTransactionActive()
        Is there a transaction currently active in the current thread?
        Returns:
        true if there is a transaction active in the current thread, false otherwise.
      • getTransactionStatus

        public static int getTransactionStatus()
        Gets the status of the transaction currently in the current thread. If there is no transaction, then Status.STATUS_NO_TRANSACTION is returned.
        Returns:
        the current transaction's status.
        See Also:
        Status
      • perform

        public <V> V perform​(Process<V> process)
        The given process is executed in a transaction: support a current transaction, create a new one if none exists. Analogous to EJB transaction attribute of the same name.
        Type Parameters:
        V - the type of the return value.
        Parameters:
        process - the process to execute in a transaction.
        Returns:
        the result of the process.
      • getStatus

        public int getStatus()
        Gets the current status of this transaction.
        Returns:
        the status code of this transaction.
        See Also:
        Status
      • performNew

        public <V> V performNew​(Process<V> process)
        The given process is executed in a new transaction, even it is called from an existent one. Analogous to EJB transaction attribute of the same name.
        Type Parameters:
        V - the type of the return value.
        Parameters:
        process - the process to execute in a transaction.
        Returns:
        the result of the process.
      • isActive

        protected boolean isActive()
      • getTransactionManager

        public javax.transaction.TransactionManager getTransactionManager()
        Gets the transaction manager behind this transaction.
        Returns:
        a TransactionManager instance.