java - HHH10001002 : Using Hibernate built-in connection pool (not for production use!)

标签 java hibernate jpa connection-pooling weblogic12c

在部署我的应用程序时,我收到此 hibernate 警告(两次):

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>

关于java - HHH10001002 : Using Hibernate built-in connection pool (not for production use!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60302533/

相关文章:

java - 使用外键关系编排 Spring Boot CrudRepositories

java - @Formula - Hibernate 中的 native 查询语法错误

spring - 集成jersey+spring+hibernate的基础webapp

java - 使用 JPA/Hibernate 在无状态应用程序中进行乐观锁定

java - 在数据库中搜索关键字

java - 如何在编辑时选择 JTable 单元格中的所有文本但在键入时不选择?

java - 从 Parse.com 获取当前时间与添加时间之间最多相差 1 小时的条目

Java:为什么在使用 Stream+Iterator 时不会发生 ConcurrentModificationException?

java - 如何使用 CSV 文件中每一行的数据在 Java 中创建对象

Hibernate Envers 修订之间的增量