【发布时间】:2019-06-23 10:57:41
【问题描述】:
我有一个包含 40 个字段的集合。
我的pojo如下
@Entity("colName")
public class Entity1 {
//Id
//10 fields - names same as collection columns
@Embedded
//Entity2
}
Entity2 类:
@Embedded
public class Entity2 {
//20 other fields
}
我查询集合如下
datastore.createQuery(Entity1.class).disableValidation().filter("fieldFromEntity1", "2227536").asList();
但我总是将 Entity2 引用设为 null。
我发现Entity2必须是嵌套文档。
有什么办法可以做到吗?
文档:
{
_id: a|b|c,
field1: stringValue,
....
field40: intgerValue
}
【问题讨论】:
-
您能分享一下该文档在数据库中的样子吗?
-
@evanchooly 请查看附件格式。在 40 个字段中,我在一个 pojo 中有 10 个,包括 id,其他的在另一个 pojo 中。我需要这个用于 REST API 响应格式。