Class TransactionScopedEntityManager

java.lang.Object
org.jboss.as.jpa.container.AbstractEntityManager
org.jboss.as.jpa.container.TransactionScopedEntityManager
All Implemented Interfaces:
jakarta.persistence.EntityManager, Serializable, AutoCloseable

public class TransactionScopedEntityManager extends AbstractEntityManager implements Serializable
Transaction scoped entity manager will be injected into SLSB or SFSB beans. At bean invocation time, they will join the active transaction if one is present. Otherwise, they will simply be cleared at the end of the bean invocation.

This is a proxy for the underlying persistent provider EntityManager.

Author:
Scott Marlow
See Also:
  • Constructor Details

    • TransactionScopedEntityManager

      public TransactionScopedEntityManager(String puScopedName, Map properties, jakarta.persistence.EntityManagerFactory emf, jakarta.persistence.SynchronizationType synchronizationType, jakarta.transaction.TransactionSynchronizationRegistry transactionSynchronizationRegistry, jakarta.transaction.TransactionManager transactionManager)
  • Method Details

    • getEntityManager

      protected jakarta.persistence.EntityManager getEntityManager()
      Specified by:
      getEntityManager in class AbstractEntityManager
    • isExtendedPersistenceContext

      protected boolean isExtendedPersistenceContext()
      Specified by:
      isExtendedPersistenceContext in class AbstractEntityManager
      Returns:
      true if an extended persistence context is in use

      Precondition: getEntityManager() must be called previous to calling isExtendedPersistenceContext

    • isInTx

      protected boolean isInTx()
      Specified by:
      isInTx in class AbstractEntityManager
      Returns:
      true if a Jakarta Transactions transaction active

      Precondition: getEntityManager() must be called previous to calling isInTx

    • close

      public void close()
      Catch the application trying to close the container managed entity manager and throw an IllegalStateException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface jakarta.persistence.EntityManager
      Overrides:
      close in class AbstractEntityManager
    • getSynchronizationType

      public jakarta.persistence.SynchronizationType getSynchronizationType()
      Specified by:
      getSynchronizationType in class AbstractEntityManager
    • deferEntityDetachUntilClose

      protected boolean deferEntityDetachUntilClose()
      return true if non-tx invocations should defer detaching of entities until entity manager is closed. Note that this is an extension for compatibility with JBoss application server 5.0/6.0 (see AS7-2781)
      Specified by:
      deferEntityDetachUntilClose in class AbstractEntityManager
    • skipQueryDetach

      protected boolean skipQueryDetach()
      return true if non-tx invocations should defer detaching of query results until entity manager is closed. Note that this is an extension for compatibility with JBoss application server 5.0/6.0 (see WFLY-12674)
      Specified by:
      skipQueryDetach in class AbstractEntityManager
    • setProperty

      public void setProperty(String propertyName, Object value)
      Specified by:
      setProperty in interface jakarta.persistence.EntityManager
      Overrides:
      setProperty in class AbstractEntityManager