2
JPAでGAE-Jでトランザクションを使用したいと思います。JPAを使用して特定のエンティティグループにオブジェクトを作成する方法は? (Google AppEngine Java)
JPAなければ、それは次のようになります。
Entity child= new Entity("Child", "ParentKey");
が、JPAでそれを行うにはどのように?
@Entity
public class Parent{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
private String text;
}
@Entity
public class Child{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
private Parent parent;
private String text;
}
しよう...
Parent parent = new Parent();
em.persist(parent);
em.refresh(parent);
Child child = new Child();
child.setParent(parent);
em.persist(child);
これは動作しません:前後に少し聞こえる
org.datanucleus.store.appengine.DatastoreRelationFieldManager$ChildWithoutParentException:
Detected attempt to establish Child(130007) as the parent of Parent(132001) but the entity identified by Child(132001) has already been persisted without a parent. A parent cannot be established or changed once an object has been persisted.
を... は私ばか者ですか?または簡単な方法はありますか?
ありがとうございます!
これらの2つのクラスは私のためにエンハンサーエラーを引き起こします。 GoogleのAppEngineのエンハンサー:java.lang.NullPointerExceptionが GoogleのAppEngineのエンハンサー:によって引き起こさorg.datanucleus.api.jpa.metadata.JPAAnnotationReader.newMetaDataForMember(JPAAnnotationReader.java:1995) GoogleのAppEngineのエンハンサーで:org.datanucleus.apiで.jpa.metadata.JPAAnnotationReader.processMemberAnnotations(JPAAnnotationReader.java:1126) – Boris
JPA 2を設定するだけで、今すぐ動作します。しかし、これはバック協会なしではこれが不可能だとは言わないのですか? – Boris