Java EclispseLink+;MongoDB并行事务
在多线程java 7应用程序中运行非常简单的示例:Java EclispseLink+;MongoDB并行事务,java,mongodb,transactions,eclipselink,Java,Mongodb,Transactions,Eclipselink,在多线程java 7应用程序中运行非常简单的示例: em.getTransaction().begin(); SimpleObject simpleObject = ...; em.persist(simpleObject); em.getTransaction().commit(); 导致以下错误: java.lang.IllegalStateException: Exception Description: Transaction is currently active 在一个线程中
em.getTransaction().begin();
SimpleObject simpleObject = ...;
em.persist(simpleObject);
em.getTransaction().commit();
导致以下错误:
java.lang.IllegalStateException: Exception Description: Transaction is currently active
在一个线程中运行一切都很好
My persistence.xml设置:
<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>
org.eclipse.persistence.jpa.PersistenceProvider
测试\简单对象
假的
已用库的版本:
日食2.5.2,
mongoDB 2.6.1,
jpa 2.1.0,
mongo-java-driver-2.12.2,
eclipse.persistence.nosql-2.5.1
有什么问题吗?
谢谢大家!