[英]JDO UnsupportedDatastoreFeatureException on Google App Engine
[英]Google App Engine JDO problem
如何存儲復雜的對象? 我在其子對象列表中有一個對象,在調用makePersistent(person)對象未保存時,該子對象有四個子對象列表。 救命!!!!!!!!!!!!
我叫pm.makePersistent(); 但清單
@Persistent
private List<ChoosedElementEntity> choosedElements = new ArrayList<ChoosedElementEntity>();
@Persistent
private List<PleasantElementEntity> pleasantElements = new ArrayList<PleasantElementEntity>();
@Persistent
private List<UnpleasantElementEntity> unpleasantElements = new ArrayList<UnpleasantElementEntity>();
@Persistent
private List<SetViewElementEntity> setViewElements = new ArrayList<SetViewElementEntity>();
沒有保存!!!
例:
@PersistenceCapable(table = "persons", identityType = IdentityType.APPLICATION)
public class PersonEntity {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private List<OfferEntity> offers = new ArrayList<OfferEntity>();
}
@PersistenceCapable(table = "offers", identityType = IdentityType.APPLICATION)
public class OfferEntity {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private List<ChoosedElementEntity> choosedElements = new ArrayList<ChoosedElementEntity>();
@Persistent
private List<PleasantElementEntity> pleasantElements = new ArrayList<PleasantElementEntity>();
@Persistent
private List<UnpleasantElementEntity> unpleasantElements = new ArrayList<UnpleasantElementEntity>();
@Persistent
private List<SetViewElementEntity> setViewElements = new ArrayList<SetViewElementEntity>();
}
@PersistenceCapable(table = "offer_selections", identityType = IdentityType.APPLICATION)
public class ChoosedElementEntity {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String code;
@Persistent
private Text cmComments;
}
@PersistenceCapable(table = "offer_selections", identityType = IdentityType.APPLICATION)
public class PleasantElementEntity {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String code;
@Persistent
private Text cmComments;
}
@PersistenceCapable(table = "offer_selections", identityType = IdentityType.APPLICATION)
public class UnpleasantElementEntity {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String code;
@Persistent
private Text cmComments;
}
@PersistenceCapable
對象層次結構中的所有類聲明為@PersistenceCapable
\n @Element(dependent =“ true”) \n 私有Set標簽= new HashSet(); \n
makePersistentAll(person)
? pm.close()
。 在關閉處理程序之前,數據永遠不會持久化,即: \n //使用pm對象處理所有對象\n PersitenceManager pm = PMF.instance()。getPersistenceManager();\n // 做工作\n //存儲更改\n pm.close()\n
對象之間的關系可能有問題嗎? 嘗試完成手動保存復雜對象中的每個對象
看來您沒有正確激活JDO中的生成器主鍵。 這不是JDO的錯誤嗎?
我找到了:
“目前存在一個錯誤,阻止了父級和子級屬於同一類的擁有的一對多關系,因此很難對樹結構進行建模。此問題將在以后的版本中修復。您可以通過存儲顯式來解決此問題。父母或孩子的鍵值。”
http://code.google.com/intl/en-EN/appengine/docs/java/datastore/usingjdo.html
我等不及要修復此問題,因此我已經通過擁有所有這種類型的實體來解決此問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.