Hitachi

uCosminexus Application Server Compatibility Guide


8.7.3 Overriding the @PersistenceUnit definition using the DD

If the <persistence-unit-ref> tag is defined in the DD when @PersistenceUnit is mentioned in the application, the contents defined in the annotation are overwritten by the contents defined in the DD. In this case, the mapping between the annotations and DD is determined with the mapping between the name attribute of @PersistenceUnit and the <persistence-unit-ref-name> tag present under the <persistence-unit-ref> tag of the DD. Note that even if the name attribute is not explicitly specified in @PersistenceUnit, the name attribute contains the default value.

The precautions to be taken when the attributes specified in @PersistenceUnit are overridden with the DD tags are as follows:

Organization of this subsection

(1) <persistence-unit-name> and unitName attribute

The <persistence-unit-name> tag of the DD overrides the unitName attribute of @PersistenceUnit. Normally, if you change the persistence unit name, the application stops operating, so take care when you make changes.

(2) <injection-target> tag

The injection target cannot be overridden with the DD. Note that when the <injection-target> tag is coded in the DD, you must accurately specify the fields and methods in which @PersistenceContext is added.