13.2.1 Details of persistence.xml
- Organization of this subsection
(1) <persistence>
The <persistence> tag is the root tag indicating the start of definition for the persistence unit.
You must set the xmlns element that specifies the XML namespace in the <persistence> tag.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
version |
persistence:versionType |
Required |
Specifies the XML schema version "1.0". |
(2) <persistence-unit>
The <persistence-unit> tag defines the persistence unit. The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Specifies the name of the persistence unit. The name that will be specified in the name attribute must be unique in the persistence unit packaging range. If a persistence unit is defined with duplicate names, the operations of Cosminexus JPA Provider cannot be guaranteed. If persistence units with the same names are defined in the Java EE environment, a warning message is output by the container. In the Java EE environment, the value specified in the name attribute should not be a null character. If a null character is specified, an exception occurs in the container. |
transaction-type |
persistence:persistence-unit-transaction-type |
Optional |
Specifies the transaction that will be used by the EntityManager.
If the value of the transaction-type attribute is not specified, the default value 'JTA' will be applied. For details on attributes that can be specified in the Java EE environment, see 8.8.1 Attributes specified in the <persistence-unit> tag. |
(3) <description>
Describes the persistence unit.
(4) <provider>
Specifies the implementation class name of javax.persistence.spi.PersistenceProvider.
When using Cosminexus JPA Provider, you specify com.hitachi.software.jpa.PersistenceProvider. You code this tag for explicit specification such as when other JPA providers exist. Note that when the value is not specified, the tag behavior depends on the container.
- Precautions
-
If you insert a space in the middle of the <provider> tag, the processing is same as the case when the element is not specified.
(5) <jta-data-source>
Specifies the references for the data source corresponding to the JTA transaction.
Specify this tag when the value specified for transaction-type in the <persistence-unit> tag is JTA. Note that when the value is not specified, the tag behavior depends on the container.
(6) <non-jta-data-source>
Specifies the references for the data source not corresponding to the JTA transaction. Specify this tag when the value specified for transaction-type in the <persistence-unit> tag is RESOURCE_LOCAL.
If a value specified for transaction-type is JTA, the value is ignored in Cosminexus JPA Provider even if that value is specified for the <non-jta-data-source> tag. When the value is not specified, the tag behavior depends on the container.
(7) <mapping-file>
Specifies the O/R mapping file.
You must store the specified file at the location specified in the class path. The <mapping-file> tag need not be coded when the O/R mapping file is not used or when orm.xml is deployed at a defined location and used.
If the specified file is not found, the application will fail to start.
(8) <jar-file>
The <jar-file> tag codes a JAR file name that includes the entity class, embeddable class, and mappedsuper class. Specify the JAR file path using the relative path from the root of the persistence unit.
If the specified file is not found, the tag behavior depends on the container.
(9) <class>
Codes the entity class, embeddable class, and mappedsuper class.
If the specified class is not found, the tag behavior depends on the container.
Note that Cosminexus JPA Provider does not implement the check to verify whether the value specified in the <class> tag is the entity class, embeddable class, and mappedsuper class. Therefore, if you specify a class other than the entity class, embeddable class, and mappedsuper class, the operation is performed without throwing an exception.
(10) <exclude-unlisted-classes>
The <exclude-unlisted-classes> tag defines the Persistence class.
The specifiable values and the behavior when the values are specified are as follows:
- true
-
Only the classes explicitly specified by the class element, the jar-file element, and the mapping-file element are handled as the Persistence classes.
- false
-
If the exclude-unlisted-class element is not specified, the class files under the persistence unit root will be searched to find out if the class is a JPA target class.
(11) <properties>
Defines the Cosminexus JPA Provider-specific properties. You specify the property element under this element to define the property.
(12) <property>
Defines various properties.
For details about the properties, see 13.2.2 Cosminexus JPA Provider-specific properties that can be specified in the <property> tag.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Property name. |
value |
xsd:string |
Required |
Property value. |