【发布时间】:2011-04-04 21:31:30
【问题描述】:
我知道这个标题非常混乱。
您好,我在这里遇到了一些奇怪的问题。
我有一个属性类,像这样
@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 从这个类继承,应该让它们共享索引,我认为...... 我应该跳过拥有的关系并选择无主的关系吗?
我觉得我可能只是错过了一些重要的东西。 有什么想法吗?
谢谢
【问题讨论】:
标签: java google-app-engine jdo datastore