Petclinic.hbm.xml, Applicationcontext-datasource.xml – HP Integrity NonStop J-Series User Manual

Page 137

Advertising
background image

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

(<My SASH
Home
>\spring\samples\petclinic\src\main\resources\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 instead of identity,
because identity is not supported by the SQL/MX database. During the Add operation, the
Hibernate Generator class increment 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 <My SASH
Home
>\spring\samples\petclinic\src\main\resources\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-dataSource.xml

(<My SASH Home>\spring\samples\petclinic\src\main\webapp\
WEB-INF\spring\applicationContext-dataSource.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-dataSource.xml file

The dataSource bean was modified to add the PetClinic database catalog and schema property.
Before the change:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
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">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="catalog" value="${jdbc.catalog}"/>
<property name="schema" value="${jdbc.schema}"/>
</bean>>

Customizing PetClinic

137

Advertising
This manual is related to the following products: