我在客户端创建了两个类,它们使用 GWT JDO 存储。
父类如下所示:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Park implements Serializable{
@PrimaryKey
@Persistent
private String parkId;
//...
@Persistent(mappedBy = "park", defaultFetchGroup = "true")
private List<Facility> facilityList;
// other stuff
孩子看起来像:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Facility implements Serializable{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
private String encodedKey;
@Persistent
private Park park;
// other stuff
在服务器端,我有一个获取所有内容的方法:
public Park[] getParks(){
PersistentManager pm = getPersistentManager();
ArrayList<Park> parkList = new ArrayList<Park>();
try {
Query q = pm.newQuery(Park.class);
List<Park> parks = (List<Park>) q.execute();
for(Park p:parks)
parkList.add(p);
} finally {
pm.close();
}
return parkList.toArray(new Park[parkList.size()]);
}
当我调用此方法时,它会引发异常:
com.google.gwt.user.client.rpc.SerializationException: Type 'org.datanucleus.store.types.sco.backed.ArrayList' is not included in the set of types which可以通过此 SerializationPolicy 进行序列化,否则无法加载其 Class 对象。出于安全目的,此类型不会被序列化。
我不知道出了什么问题。欢迎任何建议。