Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • With <persistence-unit transaction-type="TRANSACTION"> the container will do EntityManager (PersistenceContext/Cache) creating and tracking...
    • You cannot use the EntityManagerFactory to get an EntityManager
    • You can only get an EntityManager supplied by the container
    • An EntityManager can be injected via the @PersistenceContext annotation only (not @PersistenceUnit)
    • You are not allowed to use @PersistenceUnit to refer to a unit of type TRANSACTION
    • The EntityManager given by the container is a reference to the PersistenceContext/Cache associated with a JTA Transaction, if any.
    • If no JTA transaction is in progress, the EntityManager cannot be used because there is no PersistenceContext/Cache.
    • Everyone with an EntityManager reference to the same unit in the same transaction will automatically have a reference to the same PersistenceContext/Cache
    • The PersistenceContext/Cache is flushed and cleared at JTA commit time

...