Google app engine 使用@ElementCollection不适用于JPA 2的GAE
在我的Gooogle应用程序引擎项目中,我将从JPA 1迁移到JPA 2,为此,我更改了枚举集合的注释,如下所示:Google app engine 使用@ElementCollection不适用于JPA 2的GAE,google-app-engine,jpa,jpa-2.0,datanucleus,Google App Engine,Jpa,Jpa 2.0,Datanucleus,在我的Gooogle应用程序引擎项目中,我将从JPA 1迁移到JPA 2,为此,我更改了枚举集合的注释,如下所示: // @OneToMany(cascade = CascadeType.ALL) // JPA 1 @ElementCollection(targetClass=PositioningType.class) private List<PositioningType> bestPositionings; 更新1 我在尝试持久化整数集合时遇到了相同的异
// @OneToMany(cascade = CascadeType.ALL) // JPA 1
@ElementCollection(targetClass=PositioningType.class)
private List<PositioningType> bestPositionings;
更新1 我在尝试持久化整数集合时遇到了相同的异常:
@ElementCollection
@Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
//private List<PositioningType> bestPositionings = new ArrayList<PositioningType>();
private List<Integer> bestPositionings;
@ElementCollection
@扩展名(vendorName=“datanucleus”,key=“gae.unindex”,value=“true”)
//私有列表BestPositions=新的ArrayList();
私人名单排名;
结果:
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)
原因:org.datanucleus.exceptions.nucleuserexception:未找到集合字段“com.olympya.datamodel.model.Player.bestpositions”的元素类“java.lang.Integer”的元数据。
位于com.google.appengine.datanucleus.scostore.AbstractFKStore。(AbstractFKStore.java:120)
位于com.google.appengine.datanucleus.scostore.FKListStore.(FKListStore.java:83)
位于com.google.appengine.datanucleus.DatastoreManager.newFKListStore(DatastoreManager.java:472)
位于org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForCollection(MappedStoreManager.java:798)
位于org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForField(MappedStoreManager.java:709)
位于org.datanucleus.store.types.sco.backed.ArrayList.(ArrayList.java:99)
未找到整数的元数据
更新2
使用
@Basic
对字段进行注释,而不使用其他方法,可以使其正常工作。不过,仍在等待答案,因为@ElementCollection
应该有效,而@Basic
不应该用于集合。看看这个问题
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)