How to configure an eclipselink JTA sequence connection pool

[亡魂溺海] 提交于 2019-12-23 02:32:10

问题


I have been having concurrency problems with TABLE sequences on MySQL and found advise that the solution may be configuring a separate connection pool for sequence generation. In this stackoverflow question it points to the Eclipselink Documentation which has a section for an example that's empty. I can't seem to find any example of how this is configured.

My persistence.xml at the moment is below. What should I change to ensure sequence generation is executed on a seperate transaction / connection pool.

It would also be great to know what I should look for to determine it's working, other than just waiting to see if deadlocks stop occurring.

Many thanks

 <?xml version="1.0" encoding="UTF-8"?>
 <persistence 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"
     version="2.0">
        <persistence-unit name="myapp">
        <jta-data-source>jdbc/myapp</jta-data-source>
        <non-jta-data-source>jdbc/myapp/nonjta</non-jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.target-database" value="MySQL"/>
            <property name="javax.persistence.validation.mode" value="NONE" />      
            <property name="eclipselink.jdbc.sequence-connection-pool.non-jta-data-source" value="jdbc/rightcab/nonjta" />
        </properties>
    </persistence-unit>
 </persistence>

回答1:


Try also giving a non-jta-data-source,

<non-jta-data-source>jdbc/myapp/nonjta</non-jta-data-source>

You will need to create the DataSource in your application server as non-JTA.



来源:https://stackoverflow.com/questions/19732551/how-to-configure-an-eclipselink-jta-sequence-connection-pool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!