javax.persistence
Annotation Type PersistenceContext


@Target(value={TYPE,METHOD,FIELD})
@Retention(value=RUNTIME)
public @interface PersistenceContext

The PersistenceContext annotation is used to express a dependency on a container-managed entity manager persistence context.

Since:
EJB 3.0 version.
Author:
Florent Benoit
See Also:
EJB 3.0 specification

Optional Element Summary
 java.lang.String name
          The name element refers to the name by which the entity manager is to be accessed in the environment referencing context, and is not needed when dependency injection is used.
 PersistenceProperty[] properties
          The optional properties element may be used to specify properties for the container or persistence provider.
 PersistenceContextType type
          The type element specifies whether a transaction-scoped or extended persistence context is to be used.
 java.lang.String unitName
          The optional unitName element refers to the name of the persistence unit.
 

name

public abstract java.lang.String name
The name element refers to the name by which the entity manager is to be accessed in the environment referencing context, and is not needed when dependency injection is used.

Default:
""

unitName

public abstract java.lang.String unitName
The optional unitName element refers to the name of the persistence unit. If the unitName element is specified, the persistence unit for the entity manager that is accessible in JNDI must have the same name.

Default:
""

type

public abstract PersistenceContextType type
The type element specifies whether a transaction-scoped or extended persistence context is to be used. If the type element is not specified, a transaction-scoped persistence context is used.

Default:
TRANSACTION

properties

public abstract PersistenceProperty[] properties
The optional properties element may be used to specify properties for the container or persistence provider. Vendor specific properties may be included in the set of properties, and are passed to the persistence provider by the container when the entity manager is created. Properties that are not recognized by a vendor must be ignored.

Default:
{}