2016/02/07 - Apache Onami has been retired.

For more information, please explore the Attic.

public interface

EntityManagerProvider

implements Provider<T>
org.apache.onami.persist.EntityManagerProvider

Class Overview

Provider for EntityManager.

Even though this class extends the Provider interface it is not bound as a provider of EntityManager. The reason for this is that the EntityManager objects do have a life cycle and should therefore not be stored in instance/member variables.

The UnitOfWork defines the life cycle of the EntityManager. An entity manager will be created when the unit of work is started. It is open and valid for use during the entire unit of work. When the unit of work ends the entity manager is closed and can no longer be used.

It is a good practice to store this provider in a instance/member variable and only obtain an EntityManager instance in a method where it is used. This ensures that the method always has access to a valid EntityManager.

The EntityManagerProvider is thread save.

Summary

Public Methods
abstract EntityManager get()
[Expand]
Inherited Methods
From interface javax.inject.Provider

Public Methods

public abstract EntityManager get ()

Returns
  • the EntityManager.
Throws
IllegalStateException if isActive() returns false.