極其混亂的標題,我知道。在GAE數據存儲中持有同一類的不同實例
你好,我在這裏面臨一些時髦的問題。
我有一個屬性類,像這樣
@PersistenceCapable
public class Property implements Serializable
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String key;
//...
}
現在,我也有兩個其他類。讓我們稱他們爲工廠和商店。 他們都有propertys,像這樣:
@PersistenceCapable
public class Factory implements Serializable
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String key;
@Persistent
private String m_Name;
@Persistent
private List<Property> m_FactoryProperties;
}
和
@PersistenceCapable
public class Store implements Serializable
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String key;
@Persistent
private String m_Name;
@Persistent
private List<Property> m_StoreProperties;
}
雖然這看起來簡單,它不會工作。 我不知道爲什麼,即時通訊猜測其索引相關,因爲在GAE的數據查看器中有一個m_FactoryProperties_INTEGER_IDX或m_StoreProperties_INTEGER_IDX當我查看屬性實體。 (他們從不同時出現)。
(如果我重命名爲名單m_Propertys要麼不工作)...
這是不可能的? 我可以做一個FactoryProperty和StoreProperty類,但那會感覺很糟糕。 我想到的另一個解決方案是創建一個擁有屬性列表的超類,然後讓Factory和Store從這個類繼承,應該讓它們共享索引,我認爲... 我應該跳過擁有的關係和去無主嗎?
我覺得我可能會錯過一些至關重要的東西。 任何想法?
謝謝