1

Gooogle App Engine プロジェクトで JPA 1 から JPA 2 に移行しています。そのために、列挙型のコレクションの注釈を次のように変更しました。

//  @OneToMany(cascade = CascadeType.ALL) // JPA 1
    @ElementCollection(targetClass=PositioningType.class)
    private List<PositioningType> bestPositionings;

PositioningType注釈が付けられていない列挙型です。

そのコードは私に次の例外を与えています:

javax.persistence.PersistenceException: The MetaData for the element class "com.olympya.datamodel.model.PositioningType" of the collection field "com.olympya.datamodel.model.Player.bestPositionings" was not found.
at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:302)
at org.datanucleus.api.jpa.JPAEntityTransaction.commit(JPAEntityTransaction.java:122)
at com.olympya.Services.mergeUser(Services.java:102)
...
Caused by: org.datanucleus.exceptions.NucleusUserException: The MetaData for the element class "com.olympya.datamodel.model.PositioningType" of the collection field "com.olympya.datamodel.model.Player.bestPositionings" was not found.
at com.google.appengine.datanucleus.scostore.AbstractFKStore.<init>(AbstractFKStore.java:120)
at com.google.appengine.datanucleus.scostore.FKListStore.<init>(FKListStore.java:83)
at com.google.appengine.datanucleus.DatastoreManager.newFKListStore(DatastoreManager.java:472)
at org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForCollection(MappedStoreManager.java:798)
at org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForField(MappedStoreManager.java:709)
at org.datanucleus.store.types.sco.backed.ArrayList.<init>(ArrayList.java:99)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...

更新 1

整数のコレクションを永続化しようとすると、同じ例外が発生します。

@ElementCollection
@Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
//private List<PositioningType> bestPositionings = new ArrayList<PositioningType>();
private List<Integer> bestPositionings;

結果:

Caused by: org.datanucleus.exceptions.NucleusUserException: The MetaData for the element class "java.lang.Integer" of the collection field "com.olympya.datamodel.model.Player.bestPositionings" was not found.
at com.google.appengine.datanucleus.scostore.AbstractFKStore.<init>(AbstractFKStore.java:120)
at com.google.appengine.datanucleus.scostore.FKListStore.<init>(FKListStore.java:83)
at com.google.appengine.datanucleus.DatastoreManager.newFKListStore(DatastoreManager.java:472)
at org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForCollection(MappedStoreManager.java:798)
at org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForField(MappedStoreManager.java:709)
at org.datanucleus.store.types.sco.backed.ArrayList.<init>(ArrayList.java:99)

Integerのメタデータが見つかりませんでした!!!


更新 2

フィールドに で注釈を付ける@Basicだけで、正しく機能しました。ただし、ここでの回答を待っています。これ@ElementCollectionは機能するはずであり@Basic、コレクションでは使用しないでください。

4

0 に答える 0