Java Reference
In-Depth Information
The configuration file exists as META-INF/persistence.xml
and the entity classes are
in their package subdirectory
.
WAR
Packaging JPA entities in a WAR module can be a bit tricky. There are two ways to do
it. The first and easiest way is to put the JAR containing your JPA entities into the WAR
module WEB-INF/lib directory. The next listing shows how to package JPA inside an EAR
module (assuming the JAR file from listing 13.7 is used).
Listing 13.9. Structure of a WAR containing JPA entities in JARs
ActionBazaar-web.war:
WEB-INF/
classes/
...
lib/
ActionBazaar.jar
web.xml
...
But if the JPA entities aren't in a separate JAR but are instead directly part of the WAR
module itself, the following listing shows how this should be done.
Listing 13.10. Structure of a WAR containing JPA entities
Search WWH ::




Custom Search