Class MutableEntityProvider<T>

Type Parameters:
T -
All Implemented Interfaces:
EntityProvider<T>, EntityProviderChangeNotifier<T>, MutableEntityProvider<T>, JndiJtaProvider<T>, Serializable

public class MutableEntityProvider<T> extends MutableLocalEntityProvider<T> implements JndiJtaProvider<T>
An entity provider implementation that uses JTA transactions and JPA context provided by the application server. To provide a generic non EJB provider this class gets references to both UserTransaction and EntityManager via JNDI lookup.
See Also:
  • Constructor Details

    • MutableEntityProvider

      public MutableEntityProvider(Class<T> entityClass)
    • MutableEntityProvider

      public MutableEntityProvider(Class<T> entityClass, JndiAddresses jndiAddresses)
  • Method Details

    • isEntitiesDetached

      public boolean isEntitiesDetached()
      Description copied from interface: EntityProvider
      If this method returns true, all entities returned from this entity provider are explicitly detached from the persistence context before returned, regardless of whether the persistence context is extended or transaction-scoped. Thus, no lazy-loaded associations will work and any changes made to the entities will not be reflected in the persistence context unless the entity is merged.

      If this method returns false, the entities returned may be managed or detached, depending on the scope of the persistence context.

      The default value is implementation specific.

      Specified by:
      isEntitiesDetached in interface EntityProvider<T>
      Overrides:
      isEntitiesDetached in class LocalEntityProvider<T>
      Returns:
      true if the entities are explicitly detached, false otherwise.
      See Also:
    • runInTransaction

      protected void runInTransaction(Runnable operation)
      Description copied from class: MutableLocalEntityProvider
      If MutableLocalEntityProvider.isTransactionsHandledByProvider() is true, operation will be executed inside a transaction that is commited after the operation is completed. Otherwise, operation will just be executed.
      Overrides:
      runInTransaction in class MutableLocalEntityProvider<T>
      Parameters:
      operation - the operation to run (must not be null).
    • getEntityManager

      public jakarta.persistence.EntityManager getEntityManager()
      Description copied from class: LocalEntityProvider
      Gets the entity manager. If no entity manager has been set, the one returned by the registered entity manager provider is returned.
      Specified by:
      getEntityManager in interface EntityProvider<T>
      Overrides:
      getEntityManager in class LocalEntityProvider<T>
      Returns:
      the entity manager.
    • setJndiAddresses

      public void setJndiAddresses(JndiAddresses addresses)
      Specified by:
      setJndiAddresses in interface JndiJtaProvider<T>
      Parameters:
      addresses - JNDI addresses that the provider should uses to lookup UserTransaction and EntityManager
    • getJndiAddresses

      public JndiAddresses getJndiAddresses()
      Specified by:
      getJndiAddresses in interface JndiJtaProvider<T>
      Returns:
      settings that are used for JNDI lookups for UserTransaction and EntityManager