非常混乱的标题,我知道。
您好,我在这里面临一些时髦的问题。
我有一个属性类,像这样
@PersistenceCapable
public class Property implements Serializable
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String key;
//...
}
现在,我还有另外两门课。让我们称他们为工厂和商店。它们都有属性,如下所示:
@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 从这个类继承,应该让它们共享索引,我认为......我应该跳过拥有的关系并继续无主?
我觉得我可能只是错过了一些重要的东西。有任何想法吗?
谢谢