【问题标题】:Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type将 BoneCP 和 EclipseLink 与 LOCAL_RESOURCE 事务类型集成
【发布时间】:2015-12-17 23:03:47
【问题描述】:

我正在设置一个最小的工作示例,我在 Java EE (JSF) 项目中使用 EclipseLink。我的示例与以下配置和代码完美配合:

persistence.xml

<persistence
    version="2.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_2_0.xsd"
>
    <persistence-unit name="issat_PU_Local" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>pro.entity.Utilisateur</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/issat" />
            <property name="javax.persistence.jdbc.user" value="java" />
            <property name="javax.persistence.jdbc.password" value="JaVa" />
            <property name="eclipselink.logging.level.sql" value="FINE" />
            <property name="eclipselink.logging.parameters" value="true"/>
        </properties>
    </persistence-unit>
</persistence>

由于我不想使用 JTA,所以我使用 RESOURCE_LOCAL 作为事务类型,并在我的 DAO 中完全“手动”处理事务。

我现在想在我的示例中使用 BoneCP 连接池。 我应该如何精确地修改我的persistence.xml 来做到这一点?我在互联网上找到了许多使用 Hibernate 的配置示例,但我想继续使用 EclipseLink。

【问题讨论】:

    标签: jpa eclipselink connection-pooling persistence.xml bonecp


    【解决方案1】:

    我不能用 bonecp 来做,但我可以用 C3PO 建立一个池连接。 我点击了这个链接:http://javabeginnerstutorial.com/hibernate/connection-pooling-with-hibernate-4/

    我复制了依赖项和属性,但是没有将 &lt;property name="hibernate.c3p0.min_size"&gt;1&lt;/property&gt; 放在标签中,例如 this&lt;property name="hibernate.c3p0.min_size" value="1"/&gt;,否则会出错。

    最后 mi persitence.xml 是这样的:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-07
      相关资源
      最近更新 更多