8.12.39 @PersistenceContext
- Organization of this subsection
(1) Description
This annotation defines the reference of a container-managed EntityManager. This annotation is added to the class to be looked up.
The applicable targets are class, method, and field.
(2) Element
The following table lists the elements of @PersistenceContext:
Element name |
Optional/Required |
Element description |
---|---|---|
Optional |
This element specifies the lookup name of the EntityManager. |
|
Optional |
This element specifies the name of the persistence unit defined in the persistence.xml file. |
|
Optional |
This element specifies the type of lifecycle of the persistence context. |
|
Optional |
This element specifies the vendor-dependent properties specified in @PersistenceProperty. |
The details of attributes that are supported with Cosminexus JPA provider are as follows:
(a) name element
- Type
-
String
- Description
-
This element specifies the lookup name of the EntityManager.
You are not required to specify this element when using a DI.
- Default value
-
Null character string
(b) unitName element
- Type
-
String
- Description
-
This element specifies the name of the persistence unit defined in the persistence.xml file.
When the unitName element is specified, set the same name for the persistence unit used by EntityManagerFactory that can be accessed by the JNDI name space.
- Default value
-
Null character string
(c) type element
- Type
-
PersistenceContextType
- Description
-
This element specifies the type of lifecycle of the persistence context.
The following two types of values can be specified:
-
TRANSACTION: Persistence context of the transaction scope
-
EXTENDED: Extended persistence context
-
- Default value
-
TRANSACTION
(d) properties element
- Type
-
PersistenceProperty[]
- Description
-
This element specifies the vendor-dependent properties of the JPA Provider specified in @PersistenceProperty.
You can specify the value within the specifiable range of the arrays of @PersistenceProperty. For details, see 8.12.41 @PersistenceProperty.
When the properties element is specified, the properties that cannot be recognized are ignored.
- Default value
-
Blank array