1
1.-創建對象的id無法創建在app-發動機的新對象:重複主鍵(ID:長型)
// Allocate a key for the conference -- let App Engine allocate the ID
final Key<Conference> conferenceKey = factory().allocateId(profileKey, Conference.class);
// Get the Conference Id from the Key
final long conferenceId = conferenceKey.getId();
2.-創建objeto,添加ID
// Create Conference
Conference conference = new Conference(conferenceId,userId,conferenceForm);
3.-保存對象:
// Save Conference and Profile Entities
ofy().save().entities(profile,conference).now();
ofy().save().entity(conference).now();
4.-錯誤,使用相同的id倍數倍(數據存儲區谷歌)
注:與同ANDROID_CLIENT_ID(釋放模式)創建相同的對象
你所看到的是正確的,因爲ID = 1的兩個實體具有不同的父項,所以它們具有不同的密鑰。這是唯一完整的關鍵路徑 - 名稱/ ID僅在其父範圍內唯一。 – tx802
@ tx802 - 請發表評論作爲回答。這是正確的。 –