5.3. Hibernate 接続プロパティーの設定
JBoss Web Server デプロイメントの /WEB-INF/classes/META-INF/persistence.xml ファイルの設定を更新することで、Tomcat プールからの JDBC 接続を使用するように Hibernate を設定できます。
注記
Hibernate API を直接使用する場合は、hibernate.cfg.xml ファイルと同様の設定を使用します。
手順
-
/WEB-INF/classes/META-INF/persistence.xmlファイルを開きます。 Tomcat からの接続を使用するように Hibernate を設定します。
以下に例を示します。
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="dswebapp"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" /> <property name="hibernate.connection.datasource" value="java:comp/env/jdbc/DsWebAppDB"/> </properties> </persistence-unit> </persistence>