您可以通过配置Datanucleus属性来解决此问题。在persistence.xml文件中添加以下内容:
此外,如果您使用使用嵌套实体集合,则需要将“datanucleus.appengine.datanucleus.DirectMetaDataSynchronizedWithBackingStore”属性设置为“false”。
@Entity public class Parent{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
@ElementCollection(fetch = FetchType.EAGER)
private List children = new ArrayList<>();
public Key getId() {
return id;
}
public void setId(Key id) {
this.id = id;
}
public List getChildren() {
return children;
}
public void setChildren(List children) {
this.children = children;
}
}
@Entity public class Child {
private String name;
public Child() {}
public Child(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
请注意,在使用嵌套实体集合时,Child实体必须拥有无参构造函数。