Class TransactionHibernate

    • Constructor Summary

      Constructors 
      Constructor Description
      TransactionHibernate()
      Creates a new transaction object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addObserver​(ITransactionObserver observer)
      Adds an observer for this transaction.
      boolean addObserverFirst​(ITransactionObserver observer)
      Adds an observer for this transaction as the first observer in the observer list.
      void begin()  
      void close()
      Closes this transaction, rolling back any changes not committed by a previous call to ITransaction.commit(), and removes any association of this transaction from the current thread.
      void commit()  
      void dispose()  
      protected void finalize()  
      java.lang.Object getAttribute​(java.lang.String name)
      Returns the value of the named attribute, or null if no attribute of the given name exists.
      long getBeginTimeMillis()
      Returns the time when this transaction began in milliseconds since January 1, 1970 UTC.
      ITransaction getByConnectionId​(java.lang.String id)
      Returns an ITransaction that represents the same transaction but that returns the connection with the given id as default.
      java.sql.Connection getConnection()
      Returns the default jdbc connection for this transaction.
      java.sql.Connection getConnection​(java.lang.String databaseId)
      Returns the jdbc connection associated with the specified id.
      long getCreationTimeMillis()
      Returns the time this transaction object was created.
      javax.persistence.EntityManager getEntityManager()
      Returns the default entity manager for this transaction.
      javax.persistence.EntityManager getEntityManager​(java.lang.String databaseId)
      Returns the entity manager associated with the specified database.
      org.hibernate.Session getSession()
      Returns the default hibernate session for this transaction.
      org.hibernate.Session getSession​(java.lang.String databaseId)
      Returns the hibernate session associated with the specified database.
      java.lang.Throwable getTransactionCreationTrace()
      Returns a throwable used just as a trace to the transaction creation.
      boolean isActive()
      Returns true if the transaction is currently active, false otherwise.
      void removeAttribute​(java.lang.String name)
      Removes an attribute from this transaction.
      boolean removeObserver​(ITransactionObserver observer)
      Removes an observer for this transaction.
      void rollback()  
      void setAttribute​(java.lang.String name, java.lang.Object value)
      Stores an attribute in this transaction.
      void setTransactionProviderCallback​(ITransactionProviderCallback callback)
      Sets the transaction provider callback object to be used by this transaction.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getEntityManager

        public javax.persistence.EntityManager getEntityManager()
        Description copied from interface: ITransactionJPA
        Returns the default entity manager for this transaction.
        Specified by:
        getEntityManager in interface ITransactionJPA
        Returns:
        the default entity manager for this transaction.
      • getEntityManager

        public javax.persistence.EntityManager getEntityManager​(java.lang.String databaseId)
        Description copied from interface: ITransactionJPA
        Returns the entity manager associated with the specified database.
        Specified by:
        getEntityManager in interface ITransactionJPA
        Parameters:
        databaseId - the database id.
        Returns:
        the entity manager.
      • getSession

        public org.hibernate.Session getSession​(java.lang.String databaseId)
                                         throws DaoException
        Description copied from interface: ITransactionHibernate
        Returns the hibernate session associated with the specified database.
        Specified by:
        getSession in interface ITransactionHibernate
        Parameters:
        databaseId - the database id.
        Returns:
        the hibernate session.
        Throws:
        DaoException
      • close

        public void close()
        Description copied from interface: ITransaction
        Closes this transaction, rolling back any changes not committed by a previous call to ITransaction.commit(), and removes any association of this transaction from the current thread.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface ITransaction
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • isActive

        public boolean isActive()
        Description copied from interface: ITransaction
        Returns true if the transaction is currently active, false otherwise.
        Specified by:
        isActive in interface ITransaction
        Returns:
        true if the transaction is currently active, false otherwise.
      • getConnection

        public java.sql.Connection getConnection​(java.lang.String databaseId)
                                          throws DaoException
        Description copied from interface: ITransactionJdbc
        Returns the jdbc connection associated with the specified id.
        Specified by:
        getConnection in interface ITransactionJdbc
        Parameters:
        databaseId - the connection id.
        Returns:
        the jdbc connection.
        Throws:
        DaoException
      • addObserver

        public boolean addObserver​(ITransactionObserver observer)
                            throws PortalException
        Description copied from interface: ITransaction
        Adds an observer for this transaction. The observer is added only if the current observer list does not already contain it.
        Specified by:
        addObserver in interface ITransaction
        Parameters:
        observer - the observer.
        Returns:
        true if the observer was added, false otherwise.
        Throws:
        PortalException
      • addObserverFirst

        public boolean addObserverFirst​(ITransactionObserver observer)
                                 throws PortalException
        Description copied from interface: ITransactionSPI
        Adds an observer for this transaction as the first observer in the observer list. The observer is added only if the current observer list does not already contain it.
        Specified by:
        addObserverFirst in interface ITransactionSPI
        Parameters:
        observer - the observer.
        Returns:
        true if the observer was added, false otherwise.
        Throws:
        PortalException
      • removeObserver

        public boolean removeObserver​(ITransactionObserver observer)
                               throws PortalException
        Description copied from interface: ITransaction
        Removes an observer for this transaction. If the current observer list does not contain the given observer nothing happens.
        Specified by:
        removeObserver in interface ITransaction
        Parameters:
        observer - the observer.
        Returns:
        true if the observer was removed, false otherwise.
        Throws:
        PortalException
      • getBeginTimeMillis

        public long getBeginTimeMillis()
        Description copied from interface: ITransactionSPI
        Returns the time when this transaction began in milliseconds since January 1, 1970 UTC.
        Specified by:
        getBeginTimeMillis in interface ITransactionSPI
        Returns:
        the time when this transaction began in milliseconds since January 1, 1970 UTC.
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Description copied from interface: ITransaction
        Returns the value of the named attribute, or null if no attribute of the given name exists.

        Different transaction instances that refer to the same transaction (see ITransaction.getByConnectionId(String)) share the same attributes.

        Specified by:
        getAttribute in interface ITransaction
        Parameters:
        name - the name of the attribute.
        Returns:
        the value of the attribute, or null if the attribute does not exist.
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.Object value)
        Description copied from interface: ITransaction
        Stores an attribute in this transaction. If the value passed in is null, the effect is the same as calling ITransaction.removeAttribute(String).
        Specified by:
        setAttribute in interface ITransaction
        Parameters:
        name - the name of the attribute.
        value - the value to be stored.
      • removeAttribute

        public void removeAttribute​(java.lang.String name)
        Description copied from interface: ITransaction
        Removes an attribute from this transaction.
        Specified by:
        removeAttribute in interface ITransaction
        Parameters:
        name - the name of the attribute.
      • getTransactionCreationTrace

        public java.lang.Throwable getTransactionCreationTrace()
        Description copied from interface: ITransactionSPI
        Returns a throwable used just as a trace to the transaction creation. Instead of manually manipulating StackTraceElement, using a throwable also provides higher-level methods.
        Specified by:
        getTransactionCreationTrace in interface ITransactionSPI
        See Also:
        Throwable.getStackTrace()
      • getCreationTimeMillis

        public long getCreationTimeMillis()
        Description copied from interface: ITransactionSPI
        Returns the time this transaction object was created.
        Specified by:
        getCreationTimeMillis in interface ITransactionSPI
        Returns:
        the difference, measured in milliseconds, between this object creation time and midnight, January 1, 1970 UTC.