EclispseLink + MongoDB Parallel Transactions
Running a very simple example in a java 7 multithreaded application:
em.getTransaction().begin();
SimpleObject simpleObject = ...;
em.persist(simpleObject);
em.getTransaction().commit();
raises the following error:
java.lang.IllegalStateException: Exception Description: Transaction is currently active
Running in one thread is fine.
My persistence.xml settings:
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="mongo" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>test\SimpleObject</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform" />
<property name="eclipselink.nosql.connection-spec" value="org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec" />
<property name="eclipselink.nosql.property.mongo.host" value="localhost" />
<property name="eclipselink.nosql.property.mongo.port" value="27017" />
<property name="eclipselink.nosql.property.mongo.db" value="test" />
<property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.nosql.property.mongo.write-concern" value="MAJORITY" />
<property name="eclipselink.jpa.uppercase-column-names" value="true" />
</properties>
</persistence-unit>
</persistence>
The version of the libraries used: EclipseLink 2.5.2, mongoDB 2.6.1, jpa 2.1.0, mongo-java-driver-2.12.2, eclipse.persistence.nosql-2.5.1
Is there something wrong? Thank!
+3
source to share
No one has answered this question yet
Check out similar questions: