Permalink
Fetching contributors…
Cannot retrieve contributors at this time
124 lines (71 sloc) 4.51 KB

Hibernate-on-top-of-teiid Quickstart

Level Technologies Target Product Product Versions Source

Intermmediate

Teiid, Hibernate

DV

DV 6.0+

https://github.com/teiid/teiid-quickstarts

What is it?

Hibernate-on-top-of-teiid demonstrates how a hibernate4 application can take advantage of multiple data sources through a single Java Object by using the data federation capabilities of Teiid. This example will extend the Portfolio VDB, which is deployed by the vdb-datafederation quickstart, and create a view that will be mapped to a single relationally mapped object in Hibernate.

Hibernate is normally a 1 object to 1 data source mapping. By using Teiid as the data source, the integration is no longer approached from integrating at the application layer, but done at the data layer. Making it easier to join together related information to be exposed through Hibernate, rather than writing application code to merge related data.

Note
This example relies upon the vdb-datafederation example and that it needs to be deployed prior to running this example. Therefore, read the vdb-datafederation’s README.md and follow its directions before continuing.

System requirements

This example produces a WAR that is designed to be run on JBoss Enterprise Application Platform 6 or {{ book.asName }}.

Note
Correct Dependencies - Please note this example does not support working with Hibernate 3.
Note
This example relies upon the vdb-datafederation example and that it needs to be deployed prior to running this example. Therefore, read the vdb-datafederation’s README and follow its directions before continuing.

Setup

1. Build the project

  • Before building, need to set the username/password in the hibernate config file

The src/main/webapp/WEB-INF/hibernate4-teiid-quickstart-ds.xml file needs to have the user-name and password changed from user/user to the teiid user you wish to connect with.

  • Open a command line and navigate to the root directory of this quickstart

  • Build a WAR archive which will be later deployed on the server

mvn clean package

2. Run vdb-datafederation

Refer to vdb-datafederation/README.adoc to run vdb-datafederation.

3. Start the server

To start the server, open a command line and navigate to the "bin" directory under the root directory of the Teiid server and run:

./standalone.sh //For Linux
standalone.bat //for Windows

If Teiid isn’t configured in the default configuration, append the following arguments to the command to specify the configuration -c {configuration.file}

Example
./standalone.sh -c standalone-teiid.xml

4. VDB Deployment

  • run the following CLI script

  • cd to the $JBOSS_HOME/bin directory

  • execute: ./jboss-cli.sh --connect --file=${path}/teiid-quickstarts/hibernate-on-top-of-teiid/src/scripts/deploy_vdb.cli

5. Application Deployment

  • run the following CLI script

  • cd to the $JBOSS_HOME/bin directory

  • execute: ./jboss-cli.sh --connect --file=${path}/teiid-quickstarts/hibernate-on-top-of-teiid/src/scripts/deploy_war.cli

6. Verify deployment

Open the admin console(http://localhost:9990/console) to make sure the VDB is deployed. See Query Demonstrations below to demonstrate query.

7. Undeploy artifacts

If you wish to remove the deployed artifacts, do the following:

1) To undeploy the web application run the following command:

  • cd to the $JBOSS_HOME/bin directory

  • execute: ./jboss-cli.sh --connect --file=${path}/teiid-quickstarts/hibernate-on-top-of-teiid/src/scripts/remove_war.cli

2) To undeploy the Teiid VDB, run the following command:

  • cd to the $JBOSS_HOME/bin directory

  • execute: ./jboss-cli.sh --connect --file=${path}/teiid-quickstarts/hibernate-on-top-of-teiid/src/scripts/remove_vdb.cli

Query Demonstrations

Access the application

The application will be running at the following URL: http://localhost:8080/hibernate-on-top-of-teiid/.

The page should display a list of products. To add (Register) a new product, enter the following:

  • Product ID (must be unique)

  • Company Name

  • Stock Symbol

Note
the Stock Symbol entered must exist in the marketdata-price.txt file. For convenience, RHT has already been added to the file that doesn’t currently exist in the Products table.