此内容没有您所选择的语言版本。
Chapter 5. Hibernate on Enterprise Web Server
Hibernate is an object-relational mapping framework. It is packaged independently from JBoss Enterprise Web Server. This packaged version is used on all supported platforms.
Hibernate is used in the same way it is used in a regular Tomcat installation: the Hibernate JAR files are added into a deployment WAR file. Tomcat provides a default connection pooling mechanism. The pooling mechnism is defined in the
context.xml
. However, persistence.xml
and web.xml
are required. The example below shows a setting with tomcat connection pooling mechanism.
/META-INF/context.xml
defines the connection pools Tomcat should create.Example 5.1. context.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow /WEB-INF/classes/META-INF/persistence.xml
is a JPA configuration file. It defines how the application configures Hibernate to consume connections from the Tomcat pool. If you are using Hibernate API directly, use a similar configuration inhibernate.cfg.xml
.Example 5.2. persistence.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow /WEB-INF/web.xml
is a regular web application deployment file, which tells Tomcat which datasource it consumes. In Example 5.3, “web.xml” the datasource isjdbc/DsWebAppDB
.Example 5.3. web.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For details, refer to the Hibernate documentation for JBoss Enterprise Web Server.