Persistence annotations enable automatic entity discovery in JPA. However, manually specifying entity classes in persistence.xml provides additional control. But what if you want to avoid this manual step?
JPA does not provide an automatic scanning mechanism. If you omit the
For Java EE:
<jar-file>MyOrderApp.jar</jar-file> <class>com.widgets.Order</class>
For Java SE with Hibernate:
Hibernate supports auto-detection in Java SE through the hibernate.archive.autodetection property:
<persistence-unit name="eventractor" transaction-type="RESOURCE_LOCAL"> <properties> <property name="hibernate.archive.autodetection" value="class, hbm"/> <!-- Scan for annotated classes and Hibernate mapping XML files --> </properties> </persistence-unit>
While specifying
The above is the detailed content of How Can I Avoid Manually Specifying Entities in persistence.xml?. For more information, please follow other related articles on the PHP Chinese website!