Manual
Establishing the Connection
To establish the connection, specify the username and password of your NonStop system in the
hibernate.properties as shown.
hibernate.connection.username <HP NonStop Username>
hibernate.connection.password <HP NonStop Password>
Defining the Hibernate Dialect for SQL/MX Database
Enter org.hibernate.dialect.SqlmxDialect as the class name of a Hibernate dialect file
in the hibernate.properties file as shown below.
hibernate.dialect org.hibernate.dialect.SqlmxDialect
This property allows Hibernate to generate SQL optimized for SQL/MX database.
Opening a Session for Database Operation
To open a new session for database transaction, complete the following steps:
1. Configuring SessionFactory in your Java Program
2. Creating a New Session from the SessionFactory in Java
Configuring SessionFactory in your Java Program
Add the following lines to your Java program to create Hibernate SessionFactory.
private SessionFactory factory;
...
...
...
public void databaseCon()
{
Configuration cfg = new Configuration();
factory = cfg.buildSessionFactory();
...
...
...
}
Creating a New Session from the SessionFactory in Java
Add the following lines to your Java program to create a new session from the SessionFactory:
Session s = factory.openSession();
This will create the session which will be used further to perform database operation.
NOTE: To view the complete configuration snippet of the hibernate.properties file, see
the JDBC Configuration.
Specifying the Mapping Resources
Specify all the mapping files (.hbm) in your Java program as shown:
Configuration cfg = new Configuration()
.addResource("<Name of mapping file#1>")
.addResource("<Name of mapping file#2>");
For example,
If the mapping file used in your application is Item.hbm.xml and Bid.hbm.xml, specify it
as shown:
Configuration cfg = new Configuration()
.addResource("Item.hbm.xml")
.addResource("Bid.hbm.xml");
The basic configuration is ready for you to perform database operation using Hibernate.
Hibernate Framework Configurations for NonStop Systems 325