Use unitName attribute for injected JPA elements

This rule detects certain JPA PeristenceContext or PersistenceUnit annotations where the field name is the same as a persistence unit name that is defined in the persistence.xml file. This rule might require access to the persistence.xml file, which must be located in the META-INF folder. The following conditions trigger the rule:

The automatic fix will add the attribute unitName and/or name to JPA PeristenceContext or PersistenceUnit annotations.


Examples: