beautypg.com

Defining the connection url, Establishing the connection, Defining the hibernate dialect for sql/mx database – HP Integrity NonStop H-Series User Manual

Page 319: Specifying the mapping resources, Opening a session for database operation

background image


"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">



com.tandem.sqlmx.SQLMXDriver
...
...
...
...

NOTE:

The significance of the

<session-factory>

tag is explained in

Opening a Session

for Database Operation

section.

Defining the Connection URL

After you have specified the JDBC Type 2 driver, enter the location of the SQL/MX server. URLs
referring to SQL/MX use the

jdbc: protocol

and have the server host, port number embedded

within the URL.

To define the connection URL, enter the connection URL as

jdbc:sqlmx://

for the SQL/MX

database in the

hibernate.cfg.xml

file under the

<session-factory>

tag as shown:

jdbc:sqlmx://

Establishing the Connection

If you plan to use the JDBC Type 2 driver, do not specify the username and password

Add the following syntax in the

hibernate.cfg.xml

file under the

<session-factory>

tag as shown:


Defining the Hibernate Dialect for SQL/MX Database

Enter

org.hibernate.dialect.SqlmxDialect

as the Hibernate dialect class name for

SQL/MX database, in the

hibernate.cfg.xml

file under the

<session-factory>

tag.


org.hibernate.dialect.SqlmxDialect

This dialect file allows Hibernate to generate SQL that is optimized for the SQL/MX database.

Specifying the Mapping Resources

Specify all the mapping files (.hbm) in the

<mapping resource>

tag as shown:


For example:

If the mapping file used in your application is

Employee.hbm.xml

, specify it as shown:


The basic configuration is ready for you to perform database operation using Hibernate.

Opening a Session for Database Operation

To open a new session for database transaction, complete the following steps:

1.

Configuring SessionFactory in the

hibernate.cfg.xml

File

2.

Creating a New Session from the

SessionFactory

in your Java Program

Hibernate Framework Configurations for NonStop Systems

319

This manual is related to the following products: