我在客戶端創建了兩個類,它們使用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對象無法加載。爲了安全起見,這種類型不會被序列化。
我無法弄清楚什麼是錯的。任何建議都是值得歡迎的。