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.
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:
-
dialect — The fully qualified name of the InterSystems dialect class. The base dialect class is:
org.hibernate.dialect.InterSystemsIRISDialect
You can use a custom dialect class derived from this base class if you need to enable support for the Hibernate primary key generator classes.
-
driver_class — The fully qualified name of the InterSystems JDBC driver class:
com.intersystems.jdbc.IRISDriver
This class is in he InterSystems JDBC driver .jar file (see “System Settings” for details).
-
username — Username for the InterSystems IRIS namespace you want to access (default is _SYSTEM).
-
password — Password for the InterSystems IRIS namespace (default is SYS).
-
url — The URL for the InterSystems JDBC driver. The format for the URL is:
jdbc:IRIS://<host>:<port>/<namespace>
where <host> is the IP address of the machine hosting InterSystems IRIS, <port> is the SuperServer TCP port of your InterSystems IRIS instance, and <namespace> is the namespace that contains your InterSystems IRIS database data (see “Defining a JDBC Connection URL” in Using Java with InterSystems Software for more details).
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.