Petclinic.hbm.xml, Applicationcontext-hibernate.xml, Petclinic.hbm.xml applicationcontext-hibernate.xml – HP Integrity NonStop H-Series User Manual

Page 154

Advertising
background image

<param-value>/WEB-INF/applicationContext-jdbc.xml</param-value>
<param-value>/WEB-INF/applicationContext-jpa.xml</param-value>
-->

<!--
To use the JPA variant above,
you will need to enable Spring load-time weaving in your
server environment.
See PetClinic's readme and/or Spring's JPA documentation for
information on how to do this.
-->
</context-param>

petclinic.hbm.xml

(

<Spring Home>\samples\petclinic\src\petclinic.hbm.xml

)

This Hibernate mapping file is used to map database tables with the corresponding Java objects.
This file was modified to use the Hibernate Generator class as

increment

in place of

identity

,

which is supported by the SQL/MX database. During the

Add

operation, the Hibernate Generator

class

increments

, selects the max ID value for each table, increments it by 1, and then adds the

new record with this incremented ID value.

Changes to the

petclinic.hbm.xml

file

The changes to the

petclinic.hbm.xml

are as follows:

The value

identity

was replaced with

increment

for all

<generator class="identity"/>

tags in the

<Spring Home>\samples\petclinic\src\petclinic.hbm.xml

file.

Before the change:

<id name="id" column="id">
<generator class="identity"/>
</id>

After the change:

<id name="id" column="id">
<generator class="increment"/>
</id>

applicationContext-hibernate.xml

(

<Spring

Home>\samples\petclinic\war\WEB-INF\applicationContext-hibernate.xml

)

This file is used for configuring the Hibernate settings for PetClinic and was modified to add the
PetClinic database catalog and schema.

Changes to the

applicationContext-hibernate.xml

file

The

<bean>

tag was replaced with

datasource

to add the PetClinic database catalog and

schema property.
Before the change:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}"/>
</bean>

After the change:

<bean id="dataSource" class="org.springframework.samples.petclinic.datasource.SetDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>

154

Customizing Sample Applications

Advertising
This manual is related to the following products: