beautypg.com

Modifying the applicationcontext.xml file, Modifying the, Applicationcontext.xml – HP Integrity NonStop H-Series User Manual

Page 405: File

background image

this.email = email;
}

}

Modifying the

applicationContext.xml

File

Modify the

EmpInfo/WebContent/WEB-INF/applicationContext.xml

file, so that it uses

JPA

EntityManagerFactory

to connect to the employee SQL/MX database table, in place of

Hibernate SessionFactory.

To modify the

applicationContext.xml

file, complete the following steps:

1.

Specify the

EntityManagerFactory

in the

applicationContext.xml

file as shown:

class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">


2.

Remove the

<bean>

tag with the

sessionFactory

ID from the

applicationContext.xml

file.




Employee.hbm.xml




org.hibernate.dialect.SqlmxDialect
true





3.

Replace the reference of Hibernate

sessionFactory

with the JPA

entityManagerFactory

in the bean instance of the

EmployeeDao

class, as shown:





After modification, the

applicationContext.xml

file should appear as:


xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

class="org.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">

${jdbc.driver}


${jdbc.url}


${jdbc.user}


${jdbc.password}




${jdbc.catalog}

Example of Integrating JPA with Hibernate into Spring

405

This manual is related to the following products: