HHH10001002:使用 Hibernate 内置连接池(不适用于生产!)
HHH10001002: Using Hibernate built-in connection pool (not for production use!)
在部署我的应用程序时,我收到了这个休眠警告(两次):
WARN org.hibernate.orm.connections.pooling - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
我既不想使用 Hibernate 中的这些内置连接池,也不想使用 C3PO 等任何其他实现。
我尝试了很多东西,但我无法使用我的 Weblogic 应用程序服务器的连接池。
我的persistence.xml:
<persistence...
<persistence-unit name="MY-PERSISTENCE-UNIT">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>some classes...</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.datasource" value="jdbc/myDS"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jndi.class" value="weblogic.jndi.WLInitialContextFactory"/>
</properties>
</persistence-unit>
</persistence>
weblogic.xml:
...
<resource-description>
<res-ref-name>jdbc/myDS</res-ref-name>
<jndi-name>myDS</jndi-name>
</resource-description>
...
web.xml:
...
<resource-ref>
<res-ref-name>jdbc/myDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
PS:
我正在通过 Entitymanager 获取连接,但我没有任何 context.xml.
我能做什么?有人可以帮忙吗?
您不应该使用属性设置数据源。有一种标准方法可以使用 <jta-data-source>
元素向实体管理器提供数据源。
你只需要这样的东西:
<persistence...
<persistence-unit name="MY-PERSISTENCE-UNIT">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/myDS</jta-data-source>
<class>some classes...</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
</properties>
</persistence-unit>
</persistence>
在部署我的应用程序时,我收到了这个休眠警告(两次):
WARN org.hibernate.orm.connections.pooling - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
我既不想使用 Hibernate 中的这些内置连接池,也不想使用 C3PO 等任何其他实现。
我尝试了很多东西,但我无法使用我的 Weblogic 应用程序服务器的连接池。
我的persistence.xml:
<persistence...
<persistence-unit name="MY-PERSISTENCE-UNIT">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>some classes...</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.datasource" value="jdbc/myDS"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jndi.class" value="weblogic.jndi.WLInitialContextFactory"/>
</properties>
</persistence-unit>
</persistence>
weblogic.xml:
...
<resource-description>
<res-ref-name>jdbc/myDS</res-ref-name>
<jndi-name>myDS</jndi-name>
</resource-description>
...
web.xml:
...
<resource-ref>
<res-ref-name>jdbc/myDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
PS: 我正在通过 Entitymanager 获取连接,但我没有任何 context.xml.
我能做什么?有人可以帮忙吗?
您不应该使用属性设置数据源。有一种标准方法可以使用 <jta-data-source>
元素向实体管理器提供数据源。
你只需要这样的东西:
<persistence...
<persistence-unit name="MY-PERSISTENCE-UNIT">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/myDS</jta-data-source>
<class>some classes...</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
</properties>
</persistence-unit>
</persistence>