0

我使用标签@Serialize创建了一个带有pojo(ProductVariations)的实体,通过objectify在GAE中持久化:

@Entity
public class Product extends DatastoreObject{

    //Reference without the colors and size information
    @Index private String ref;
    private double price;
    private String details;
    private String description;
    @Serialize private ProductVariations pVariations;
    private List<String> tags = new ArrayList<String>();

//Getters & Setters
}

问题是我看不到如何使用 requestfactory 访问我的 pojo,因为 ProductVariations 不是域类型。

在任何其他情况下,我都会使用嵌入对象,但在这种特殊情况下,我在 ProductVariations 中有一个嵌套集合,女巫本身就是一个集合(ProductVariations 扩展了 ArrayList)。

关于如何实现这一目标的任何建议?

谢谢你。

4

1 回答 1

0

不确定我是否理解您的问题,但是如果您想通过 RPC 发送它,您需要在 Product 中实现 Serializable。

除此之外,您是否在存储 ProductVariations 时遇到问题?这是一个有趣的概念。如果它不起作用:

您可以将 ProductVariations 保留在自己的 @Entity 中吗?

然后在 Product 类中保留一个 Key(或可以从中创建 Key 的 Long)。

为方便起见,您也可以将 ProductVariations 留在 Product 中,但用 @Transient 标记它,然后从执行您的 ofy.get() 的工厂中的 Key/Long 填充它。

于 2013-08-30T17:44:05.137 回答