Este conteúdo não está disponível no idioma selecionado.
Chapter 5. Configuring Hibernate for JBoss Web Server
Hibernate Object/Relational Mapping (ORM) is an object-relational mapping framework that you can use to connect JBoss Web Server to Java database connectivity (JDBC) datasources. You can use Hibernate ORM with JBoss Web Server when you want to store your application data in a relational database.
5.1. Installing Hibernate ORM Copiar o linkLink copiado para a área de transferência!
You can install Hibernate ORM on all platforms that JBoss Web Server supports.
Prerequisites
You have configured your project to use the JBoss Web Server Maven Repository.
NoteThe JBoss Web Server Maven Repository is available to download as
jboss-web-server-5.6.0-maven-repository.zip. from the Red Hat Software Downloads page.
Procedure
- Get the Hibernate JAR files from the JBoss Web Server Maven Repository.
- Add the Hibernate JAR files to your deployment WAR file.
5.2. Configuring JDBC connection pools Copiar o linkLink copiado para a área de transferência!
Apache Tomcat provides a default connection pooling mechanism for JDBC datasources. You can configure JDBC connection pools by updating settings in the /META-INF/context.xml file for your JBoss Web Server deployment.
Procedure
-
Open the
/META-INF/context.xmlfile. Modify the JDBC connection pools that are available to applications.
For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.3. Configuring Hibernate connection properties Copiar o linkLink copiado para a área de transferência!
You can configure Hibernate to use JDBC connections from the Tomcat pool, by updating settings in the /WEB-INF/classes/META-INF/persistence.xml file for your JBoss Web Server deployment.
If you want to use the Hibernate API directly, use a similar configuration to the hibernate.cfg.xml file.
Procedure
-
Open the
/WEB-INF/classes/META-INF/persistence.xmlfile. Configure Hibernate to consume connections from Tomcat.
For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Adding JDBC data sources Copiar o linkLink copiado para a área de transferência!
You can configure Tomcat to consume JDBC data sources, by updating settings in the /WEB-INF/web.xml file for your JBoss Web Server deployment.
Procedure
-
Open the
/WEB-INF/web.xmlfile. Configure JDBC datasources with the
resource-env-refelement.For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe preceding example uses a a
jdbc/DsWebAppDBdata source.