Modifying the employeedao.java file – HP Integrity NonStop J-Series User Manual
Page 254

${jdbc.catalog}
${jdbc.schema}
Modifying the EmployeeDao.java File
Modify the EmployeeDao.java file, to use JPA in place of Hibernate for the insert, delete, and
retrieve operations.
To modify the EmployeeDao.java file, complete the following steps:
1.
Instantiate the JPA as shown:
private EntityManagerFactory entityManagerFactory;
public void setEntityManagerFactory(
EntityManagerFactory entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
}
2.
Add the following import statements to enable the JPA EntityManagerFactory and to
use the EntityEmployee.java class file.
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import com.hp.empinfo.domain.EntityEmployee;
3.
Remove the following import statements that were used by Hibernate:
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
4.
Modify the following methods to use JPA EntityManagerFactory to perform database
operations:
254 Integrating Frameworks