docs.intersystems.com
Home  /  Application Development: Language Bindings and Gateways  /  InterSystems Implementation Reference for Java Third Party APIs  /  Hibernate Support


InterSystems Implementation Reference for Java Third Party APIs
Hibernate Support
[Back] 
InterSystems: The power behind what matters   
Search:  


The InterSystems Hibernate Dialect is an implementation of the Hibernate dialect interface. Since every vendor’s implementation of SQL is slightly different, the dialect interface allows vendors to create custom Hibernate mappings for a specific database. Vendor-provided dialect implementations are distributed as part of Hibernate.
This chapter provides technical details about the InterSystems Hibernate Dialect. The following topics are discussed:
Hibernate and the InterSystems Hibernate Dialect
Java Persistence Architecture (JPA) is the recommended persistence technology for complex object hierarchies in Java projects. InterSystems currently supports JPA via the Hibernate implementations of the JPA specifications. Hibernate is an open source framework from JBoss that acts as a wrapper around JDBC to provide object/relational mapping (ORM) services for relational databases. Hibernate provides a vendor-neutral persistence service, which may be a requirement for some projects.
The InterSystems Hibernate Dialect is an implementation of the Hibernate dialect interface. Since every vendor’s implementation of SQL is slightly different, Hibernate includes vendor-provided "dialects" that customize its mappings to specific databases. Current Hibernate distributions include a high performance, customized InterSystems dialect class.
When to Use Hibernate
Hibernate provides the infrastructure to persist objects to relational tables. Essentially, it is a wrapper around JDBC that allows you to focus on working with objects while transparently handling conversion between objects and tables in SQL queries. Hibernate can be used in most environments, but it is not always the best option. Here are some considerations to bear in mind:
Installation and Configuration
This section provides instructions for setting up your system to use Hibernate with InterSystems IRIS. The instructions assume that the correct versions of both InterSystems IRIS and Hibernate are installed and operational.
Requirements
The following software must be installed on your system:
Directories
The instructions in this chapter refer to the following directories:
System Settings
Make the following changes to your system:
Hibernate Configuration
In the Hibernate configuration files (either hibernate.properties or hibernate.cfg.xml), specify the connection information for your database, and the name of the InterSystems dialect class.
The following five configuration properties are required:
A typical entry in hibernate.properties would contain the following lines (change url, username, and password as appropriate for your system)):
  hibernate.dialect org.hibernate.dialect.InterSystemsIRISDialect
  hibernate.connection.driver_class com.intersystems.jdbc.IRISDriver
  hibernate.connection.url jdbc:IRIS://127.0.0.1:51773/USER/
  hibernate.connection.username _SYSTEM
  hibernate.connection.password SYS
The following example shows the same information as it would appear in hibernate.cfg.xml:
  <hibernate-configuration>
    <session-factory>
      <property name="dialect">
        org.hibernate.dialect.InterSystemsIRISDialect
      </property>
      <property name="connection.driver_class">
        com.intersystems.jdbc.IRISDriver</property>
      <property name="connection.username">_SYSTEM</property>
      <property name="connection.password">SYS</property>
      <property name="connection.url">
        jdbc:IRIS://127.0.0.1:51773/USER
      </property>
    </session-factory>
  </hibernate-configuration>
Caution:
If the same property is set in both hibernate.properties and hibernate.cfg.xml, Hibernate will use the value from hibernate.cfg.xml.
Dialect File Locations
The InterSystems Hibernate dialect consists of four files that should be located as follows
(where <hibernate> is hibernate-orm\hibernate-core\src\main\java\org\hibernate):
If you do not already have these files, contact the InterSystems Worldwide Response Center (WRC) for download information.