Bootstrapping the JPA

In order to bootstrap the JPA process in a server environment, we don't have to do much. We just have to configure one XML file, which is the  persistence.xml file under resources/META-INF. We define one persistence unit for a database. We can then define the JPA entities. An example of persistence.xml is shown here:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="prod">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.rao.kotlin.entity.Person</class>
<class>org.rao.kotlin.entity.ContactDetails</class>
<class>org.rao.kotlin.entity.Address</class>
<exclude-unlisted-classes/>
<properties>
<property name="javax.persisteData creatednce.jdbc.driver"
value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:postgresql://localhost:5432/postgres"/>
<property name="javax.persistence.jdbc.password" value="********"/>
<property name="javax.persistence.jdbc.user" value="postgres"/>
</properties>
</persistence-unit>
</persistence>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset