Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Objectify 5-过滤器嵌入实体字段不';行不通_Java_Google App Engine_Objectify_Google Cloud Datastore - Fatal编程技术网

Java Objectify 5-过滤器嵌入实体字段不';行不通

Java Objectify 5-过滤器嵌入实体字段不';行不通,java,google-app-engine,objectify,google-cloud-datastore,Java,Google App Engine,Objectify,Google Cloud Datastore,我尝试从我自己的类“Payment”加载一个对象列表。现在我不想加载所有付款,只想加载那些有特定“组”作为父级的付款(组也是自己的类) 这是付款类别: @Entity public class Payment { @Id private Long id; @Index @Load private Ref<Group> parent; // other fields, constructors, getters and setters } 以下是我尝试加载此付

我尝试从我自己的类“Payment”加载一个对象列表。现在我不想加载所有付款,只想加载那些有特定“组”作为父级的付款(组也是自己的类)

这是付款类别:

@Entity
public class Payment {
    @Id private Long id;
    @Index @Load private Ref<Group> parent;
    // other fields, constructors, getters and setters
}
以下是我尝试加载此付款列表的方法:

public static List<Payment> getPaymentsByGroup(Group group) {
    List<Payment> payments = ofy().load().type(Payment.class)
            .filter("parent.id", group.getId()).list();
    return payments;
}
公共静态列表getPaymentsByGroup(组){
列表付款=ofy().load().type(Payment.class)
.filter(“parent.id”,group.getId()).list();
归还款项;
}
但结果总是一个空列表。但如果我尝试这样做:

public static List<Payment> getPaymentsByGroup(Group group) {
    List<Payment> temp = new ArrayList<>();
    List<Payment> payments = ofy().load().type(Payment.class).list();
    for (Payment payment : payments) {
        if(payment.getParent().getId().equals(group.getId())){
            temp.add(payment);
        }
    }
    return temp;
}
公共静态列表getPaymentsByGroup(组){
List temp=new ArrayList();
List payments=ofy().load().type(Payment.class).List();
用于(付款:付款){
如果(payment.getParent().getId().equals(group.getId())){
临时添加(付款);
}
}
返回温度;
}
我会拿到付款的。我使用objectify5。由于性能原因,Payment类应该是自己的实体,而不是作为普通的嵌入对象存储在Group类中。否则,必须通过添加一个付款来存储整个组对象和所有付款


我做错了什么?如何筛选嵌入实体中的字段?

我认为您可能会混淆这里的术语,因为我没有看到
@Parent
(实体组)或嵌入实体。我确实看到了一个
Ref
,它本质上是一个键

如果您将查询更改为

List payments=ofy().load().type(Payment.class).filter(“parent=,Ref.create(group)).List()


它应该会起作用。

我认为您可能会混淆这里的术语,因为我没有看到
@父对象(实体组)或嵌入式实体。我确实看到了一个
Ref
,它本质上是一个键。如果将查询更改为
List payments=ofy().load().type(Payment.class).filter(“parent=”,Ref.create(group)).List()?哦,谢谢你解决了我的问题。我试过类似的方法,但没用。特坎!很高兴听到。我已经添加了我的评论,以备您接受。
public static List<Payment> getPaymentsByGroup(Group group) {
    List<Payment> temp = new ArrayList<>();
    List<Payment> payments = ofy().load().type(Payment.class).list();
    for (Payment payment : payments) {
        if(payment.getParent().getId().equals(group.getId())){
            temp.add(payment);
        }
    }
    return temp;
}