O'Reilly logo

Java EE 7 Development with WildFly by Francesco Marchioni, Michal Matloka, Michal Cmil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring persistence

The Entity API looks great and is very intuitive, but how does the server know which database is supposed to store/query the entity objects? The persistence.xml file, which will be placed under src/main/resources/META-INF of your project, is the standard JPA configuration file. By configuring this file, you can easily switch from one persistence provider to another and thus, also from one application server to another (believe it or not, this is a huge leap towards application server compatibility).

In the persistence.xml file, we will basically need to specify the persistence provider and the underlying data source used. Simply create the following file under src/main/resources/persistence.xml:

<?xml version="1.0" encoding="UTF-8"?> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required