我在哪里可以使用JPA / Google App Engine设置TransactionOptions? [英] Where do I set TransactionOptions with JPA / Google App Engine?

查看:97
本文介绍了我在哪里可以使用JPA / Google App Engine设置TransactionOptions?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  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 $ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆