我在客户端创建了两个类,它们使用GWT JDO存储。
父类的样子:从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.t ypes.sco.backed.ArrayList'未包含在可由此SerializationPolicy序列化的类型集合中,或者其Class对象无法加载。为了安全起见,这种类型不会被序列化。
我无法弄清楚什么是错的。任何建议都是值得欢迎的。