我在哪里可以使用JPA / Google App Engine设置TransactionOptions? [英] Where do I set TransactionOptions with JPA / Google App Engine?
问题描述
javax.persistence.PersistenceException:非法参数
at org .datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:298)
在org.datanucleus.api.jpa.JPAEntityTransaction.commit(JPAEntityTransaction.java:122)
引起的:java.lang中.IllegalArgumentException:跨集团的交易需要被明确指定,见TransactionOptions.Builder.withXGfound都
元素{
型: 事件
编号:0x11000000000000
}
和元素{
类型:用户
id:0x14000000000000
}
从错误消息中我看到我需要调整 TransactionOptions
。我可以在哪里设置这些选项?
在 persistence.xml $ c中设置以下属性
$ b
< property name =datanucleus.appengine.datastoreEnableXGTransactionsvalue =true/>
目前没有办法为单个JDO或JPA事务启用XG事务。相反,您可以为所有交易指定此值。 [docs]
I use JPA within GAE to persist objects.
javax.persistence.PersistenceException: Illegal argument
at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:298)
at org.datanucleus.api.jpa.JPAEntityTransaction.commit(JPAEntityTransaction.java:122)
Caused by: java.lang.IllegalArgumentException: cross-group transaction need to be explicitly specified, see TransactionOptions.Builder.withXGfound both
Element {
type: "Event"
id: 0x11000000000000
}
and Element {
type: "User"
id: 0x14000000000000
}
There is a bidirectional Many-To-Many relationship between Event and User. When I insert a new Event and bound it to existing Users inside a transaction, I get the above exception.
From the error message I see that I need to tweak TransactionOptions
. Where can I set these options?
Set the following property in persistence.xml
:
<property name="datanucleus.appengine.datastoreEnableXGTransactions" value="true" />
There is currently no way to enable XG transactions for an individual JDO or JPA transaction. Instead, you specify this for all transactions. [docs]
这篇关于我在哪里可以使用JPA / Google App Engine设置TransactionOptions?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!