Class EntityTransactionImpl

  • All Implemented Interfaces:
    javax.persistence.EntityTransaction

    public class EntityTransactionImpl
    extends java.lang.Object
    implements javax.persistence.EntityTransaction
    JDK 1.5 version of the EntityTransaction. Differs from base version only in that it takes a JDK 1.5 version of the EntityTransactionWrapper.
    See Also:
    EntityTransactionImpl
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean active  
      protected org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.TransactionFinalizer finalizer  
      static boolean isFinalizedRequired
      PERF: Avoid finalization if not required by the application, and finalizers have major concurrency affects.
      protected java.util.WeakHashMap<QueryImpl,​QueryImpl> openQueriesMap
      Keep a weak reference to the open queries that are executed in this entity manager.
      protected boolean rollbackOnly  
      protected EntityTransactionWrapper wrapper  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addOpenQuery​(QueryImpl query)
      Queries that leave the connection and are executed against this entity manager will be added here.
      void begin()
      Start the current transaction.
      protected void closeOpenQueries()
      Open queries within a transaction will be closed on commit or rollback if they haven't already been closed.
      void commit()
      Commit the current transaction, writing any un-flushed changes to the database.
      protected java.util.Map<QueryImpl,​QueryImpl> getOpenQueriesMap()
      Return the weak reference to the open queries.
      boolean getRollbackOnly()
      Determine whether the current transaction has been marked for rollback.
      boolean isActive()
      Check to see if the current transaction is in progress.
      void rollback()
      Roll back the current transaction, discarding any changes that have happened in this transaction.
      void setRollbackOnly()
      Mark the current transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.
      • Methods inherited from class java.lang.Object

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

      • openQueriesMap

        protected java.util.WeakHashMap<QueryImpl,​QueryImpl> openQueriesMap
        Keep a weak reference to the open queries that are executed in this entity manager.
      • active

        protected boolean active
      • rollbackOnly

        protected boolean rollbackOnly
      • finalizer

        protected org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.TransactionFinalizer finalizer
      • isFinalizedRequired

        public static boolean isFinalizedRequired
        PERF: Avoid finalization if not required by the application, and finalizers have major concurrency affects.
    • Method Detail

      • addOpenQuery

        public void addOpenQuery​(QueryImpl query)
        Queries that leave the connection and are executed against this entity manager will be added here. On rollback or commit any left over open queries should be closed.
        Parameters:
        query -
      • begin

        public void begin()
        Start the current transaction. This can only be invoked if isActive() returns false.
        Specified by:
        begin in interface javax.persistence.EntityTransaction
        Throws:
        java.lang.IllegalStateException - if isActive() is true.
      • closeOpenQueries

        protected void closeOpenQueries()
        Open queries within a transaction will be closed on commit or rollback if they haven't already been closed.
      • commit

        public void commit()
        Commit the current transaction, writing any un-flushed changes to the database. This can only be invoked if isActive() returns true.
        Specified by:
        commit in interface javax.persistence.EntityTransaction
        Throws:
        java.lang.IllegalStateException - if isActive() is false.
      • rollback

        public void rollback()
        Roll back the current transaction, discarding any changes that have happened in this transaction. This can only be invoked if isActive() returns true.
        Specified by:
        rollback in interface javax.persistence.EntityTransaction
        Throws:
        java.lang.IllegalStateException - if isActive() is false.
      • setRollbackOnly

        public void setRollbackOnly()
        Mark the current transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.
        Specified by:
        setRollbackOnly in interface javax.persistence.EntityTransaction
        Throws:
        java.lang.IllegalStateException - if isActive() is false.
      • getOpenQueriesMap

        protected java.util.Map<QueryImpl,​QueryImpl> getOpenQueriesMap()
        Return the weak reference to the open queries.
      • getRollbackOnly

        public boolean getRollbackOnly()
        Determine whether the current transaction has been marked for rollback.
        Specified by:
        getRollbackOnly in interface javax.persistence.EntityTransaction
        Throws:
        java.lang.IllegalStateException - if isActive() is false.
      • isActive

        public boolean isActive()
        Check to see if the current transaction is in progress.
        Specified by:
        isActive in interface javax.persistence.EntityTransaction