Interface EntityManagerProvider

All Known Implementing Classes:
ContainerManagedEntityManagerProvider, FactoryBasedEntityManagerProvider, SimpleEntityManagerProvider

public interface EntityManagerProvider
Provides components with an EntityManager to access the persistence mechanism. Depending on the application environment, this may be a single container managed EntityManager, or an application managed instance for one-time use.

The returned entity manager's transactional lifecycle (commit, rollback, and close) is never managed by EntityManagerExecutor or any other consumer of this interface; it remains entirely the responsibility of whatever owns the entity manager on the other end of this provider, such as a container's transaction manager binding it to the current unit of work.

Since:
1.3
Author:
Allard Buijze, John Hendrikx
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.persistence.EntityManager
    Returns the EntityManager instance to use.
  • Method Details

    • getEntityManager

      jakarta.persistence.EntityManager getEntityManager()
      Returns the EntityManager instance to use.

      The caller must never commit, roll back, or close the returned entity manager directly; its lifecycle is managed externally by whatever this provider obtained it from.

      Returns:
      the entity manager instance to use, never null