Chapter 4. Configuring Hibernate for Red Hat JBoss Web Server
Hibernate ORM is an object-relational mapping framework that lets you connect JBoss Web Server to JDBC datasources.
4.1. Installing Hibernate ORM Copy linkLink copied to clipboard!
Complete the following procedure to install Hibernate ORM on all platforms that JBoss Web Server supports.
Prerequisites
Configure your project to use the JBoss Web Server Maven Repository, which is available to download as jboss-web-server-5.3.0-maven-repository.zip.
Procedure
- Get the Hibernate JAR files from the JBoss Web Server Maven Repository.
- Add the Hibernate JAR files to your deployment WAR file.
4.2. Configuring JDBC Connection Pools Copy linkLink copied to clipboard!
Tomcat provides a default connection pooling mechanism for JDBC datasources.
Procedure
-
Open your deployment’s
/META-INF/context.xmlfile for editing. Modify the JDBC connection pools available to applications, as in the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3. Configuring Hibernate Connection Properties Copy linkLink copied to clipboard!
Configure Hibernate to use connections from the Tomcat pool. If you use the Hibernate API directly, use a similar configuration to hibernate.cfg.xml.
Procedure
-
Open your deployment’s
/WEB-INF/classes/META-INF/persistence.xmlfile for editing. Configure how Hibernate consumes connections from the Tomcat, as in the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4. Adding JDBC Data Sources Copy linkLink copied to clipboard!
Configure Tomcat to consume JDBC datasources.
Procedure
-
Open your deployment’s
/WEB-INF/web.xmlfile for editing. Configure JDBC datasources with the
resource-env-refelement, as in the following example that uses ajdbc/DsWebAppDBdatasource:Copy to Clipboard Copied! Toggle word wrap Toggle overflow