此内容没有您所选择的语言版本。
Chapter 5. Hibernate on Enterprise Web Server
Hibernate is an object-relational mapping framework. It is delivered in a separate package and the same package can be used on all supported platforms.
Hibernate can be used in the same way it is used in a regular Tomcat installation; that is, the Hibernate JAR files can be added into your deployment WAR file. Tomcat provides a connection pooling mechanism by default, and you should consider taking advantage of it (the pooling mechanism 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.