Creating the persistence.xml file, Creating the entityemployee.java file – HP Integrity NonStop H-Series User Manual
Page 403

Modifying the EmpInfo application involves the following activities:
1.
Creating the persistence.xml File
2.
Creating the EntityEmployee.java File
3.
4.
5.
Removing the Employee.hbm.xml File
6.
Creating the
persistence.xml
File
Create the
persistence.xml
file to define a persistence unit called Empinfo to define a set of
classes and their mapping characteristics.
To create
persistence.xml
, complete the following steps:
1.
Create a folder named META-INF in the
EmpInfo/src
directory, as explained in the
Configuring the JSP Standard Tag Library
section in the
chapter.
2.
Create a new XML file
persistence.xml
in the
EmpInfo/src
/
META-INF
directory, as
explained in the
section in the
chapter.
3.
Modify the
persistence.xml
file to provide the persistence unit named Empinfo and
Hibernate-related configuration.
After modification, the
persistence.xml
file appears as:
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
Creating the
EntityEmployee.java
File
EntityEmployee.java
is a JPA Persistence class. This class is used to map the database entities
using JPA annotations such as @Entity, @Id, and @Basic.
To create the
EntityEmployee.java
class under the
com.hp.empinfo.domain
package,
complete the following steps:
1.
Create the Java class
EntityEmployee.java
, as explained in the
section in the
chapter.
2.
Modify the
EntityEmployee.java
class to add the application properties and their getter
and setter methods to map with the Employee database table.
After modification, the
EntityEmployee.java
appears as:
package com.hp.empinfo.domain;
import javax.persistence.Basic;
import javax.persistence.Entity;
Example of Integrating JPA with Hibernate into Spring
403