... |
h1. Configuration |
For the most part, interacting with Teiid VDBs (Virtual Databases) from Hibernate is no different from working with any other type of data source. First you must place Teiid JDBC API client JAR file and Teiid's hibernate dialect JAR in Hibernate’s classpath. These files can be found in {{<jboss-install>/server/<profile>/lib}} directory. |
For the most part, interacting with Teiid VDBs (Virtual Databases) through Hibernate is no different from working with any other type of data source. First, depending on where your Hibernate application will reside, either in the same VM as the Teiid Runtime or on a separate VM, will determine which jar's are used. * Running in same VM in the JBoss AS server, then the teiid-client-{version}.jar and teiid-hibernate-dialect-{version}.jar already reside in <jboss-install>/modules/org/jboss/teiid/client * Running separate VM's,you need the Teiid JDBC Driver JAR and Teiid's Hibernate Dialect JAR in the Hibernate's classpath. The Hibernate JAR can be found in <jboss-install>/modules/org/jboss/teiid/client, teiid-hibernate-dialect-{version}.jar and the [Teiid JDBC Driver JAR|http://www.jboss.org/teiid/downloads.html] needs to be downloaded. |
|
* teiid-\{version}-jdbc.jar * teiid-hibernate-dialect-\{version}.jar |
These JAR files have the {{org.teiid.dialect.TeiidDialect}} and {{org.teiid.jdbc.TeiidDriver}} and {{org.teiid.jdbc.TeiidDataSource}} classes. |
You then configure Hibernate (via hibernate.cfg.xml) as follows: |
* Specify the Teiid driver class in the "connection.driver_class" property: |
... |
For the most part, interacting with Teiid VDBs (Virtual Databases) through Hibernate is no different from working with any other type of data source. First, depending on where your Hibernate application will reside, either in the same VM as the Teiid Runtime or on a separate VM, will determine which jar's are used.
.jar and teiid-hibernate-dialect-
.jar already reside in <jboss-install>/modules/org/jboss/teiid/client
.jar and the Teiid JDBC Driver JAR needs to be downloaded.
These JAR files have the org.teiid.dialect.TeiidDialect and org.teiid.jdbc.TeiidDriver and org.teiid.jdbc.TeiidDataSource classes.
You configure Hibernate (via hibernate.cfg.xml) as follows:
<property name="connection.driver_class"> org.teiid.jdbc.TeiidDriver </property>
<property name="connection.url"> jdbc:teiid:<vdb-name>@mm://<host>:<port>;user=<user-name>;password=<password> </property>
Be sure to use a Local JDBC Connection if Hibernate is in the same VM as the application server. |
<property name="dialect"> org.teiid.dialect.TeiidDialect </property>
Alternatively, if you put your connection properties in hibernate.properties instead of hibernate.cfg.xml, they would look like this:
hibernate.connection.driver_class=org.teiid.jdbc.TeiidDriver hibernate.connection.url=jdbc:teiid:<vdb-name>@mm://<host>:<port> hibernate.connection.username=<user-name> hibernate.connection.password=<password> hibernate.dialect=org.teiid.dialect.TeiidDialect
Note also that since your VDBs will likely contain multiple source and view models with identical table names, you will need to fully qualify table names specified in Hibernate mapping files:
<class name="<Class name>" table="<Source/view model name>.[<schema name>.]<Table name>"> ... </class>
<class name="org.teiid.example.Publisher" table="BOOKS.BOOKS.PUBLISHERS"> ... </class>