Jonathan
Jonathan

Reputation: 400

How to configure an eclipselink JTA sequence connection pool

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>

Upvotes: 1

Views: 1843

Answers (1)

James
James

Reputation: 18379

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.

Upvotes: 1

Related Questions