Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.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 对象化子类中的Ref_Java_Google App Engine_Filtering_Subclass_Objectify - Fatal编程技术网

Java 对象化子类中的Ref

Java 对象化子类中的Ref,java,google-app-engine,filtering,subclass,objectify,Java,Google App Engine,Filtering,Subclass,Objectify,我正试图得到一份通过参照选择的清单 我的课程是: 在守护进程上运行的许可证 许可证可以是LicenseCountryCondition或另一个带有Ref的子类(对于LicenseCountryCondition,参数是国家的Ref) 许可证: @Entity @Cache @Index public class License { @Id Long id; private String name; private String startDate; p

我正试图得到一份通过参照选择的清单

我的课程是:

  • 在守护进程上运行的许可证
  • 许可证可以是LicenseCountryCondition或另一个带有Ref的子类(对于LicenseCountryCondition,参数是国家的Ref)
许可证:

@Entity
@Cache
@Index
public class License {
    @Id
    Long id;
    private String name;
    private String startDate;
    private String expDate;
    private int timeStamp;
    private int status;
    Ref<Daemon> daemon;
    private boolean inactive;
}
@Index
@Subclass(index=true)
public class LicenseCountryCondition extends License{
    Ref<Country> country;
}
@实体
@缓存
@索引
公共类许可证{
@身份证
长id;
私有字符串名称;
私有字符串起始日期;
私有字符串expDate;
私有整数时间戳;
私人身份;
Ref守护进程;
私有布尔不活动;
}
被许可国条件:

@Entity
@Cache
@Index
public class License {
    @Id
    Long id;
    private String name;
    private String startDate;
    private String expDate;
    private int timeStamp;
    private int status;
    Ref<Daemon> daemon;
    private boolean inactive;
}
@Index
@Subclass(index=true)
public class LicenseCountryCondition extends License{
    Ref<Country> country;
}
@Index
@子类(索引=true)
公共类许可证CountryCondition扩展许可证{
参考国;
}
如果我想找到在特定守护进程上工作的LicenseConomryCondition的列表,我会执行以下操作:

Daemon dae=ofy().load().type(Daemon.class).filter("name", "example").first().now();  

    List<LicenseCountryCondition>test=ofy().load().type(LicenseCountryCondition.class).filter("daemon",dae).list();
                for(LicenseCountryCondition i:test){
                    System.out.println(i.getName());
                    System.out.println(i.getDaemon().getName());
                }
Daemon dae=ofy().load().type(Daemon.class).filter(“name”,“example”).first().now();
Listtest=ofy().load().type(LicenseCountryCondition.class).filter(“守护进程”,dae).list();
用于(许可证国家条件i:测试){
System.out.println(i.getName());
System.out.println(i.getDaemon().getName());
}
我得到了很好的结果

但是,当我试图获取在特定国家工作的被许可国条件的列表时,它不起作用:

Country ctr=ofy().load().type(Country.class).filter("name", "France").first().now();
    List<LicenseCountryCondition> test=ofy().load().type(LicenseCountryCondition.class).filter("country",ctr).list();
        for(LicenseCountryCondition i:test){
            System.out.println(i.getName());
        }
Country ctr=ofy().load().type(Country.class).filter(“name”,“France”).first().now();
List test=ofy().load().type(LicenseCountryCondition.class).filter(“country”,ctr).List();
用于(许可证国家条件i:测试){
System.out.println(i.getName());
}
能给我这张单子吗?(我看到了,但不是同一个问题)


感谢您的关注。

请确保您对法国的查询实际返回一个真实的国家(非空)


你写的东西没有什么明显的错误,但是这里有太多的东西,太多未指定的数据库状态,让人无法回答这个问题。最好的做法是组合一个测试用例,创建一些实体(因此db状态是已知的),然后演示您认为应该成功但仍然失败的查询。

谢谢您的回答。我不知道为什么,但当我今天早上尝试时,它起了作用。我只是看到我的两个LicenceCountryCondition仍然未编制索引,我想我昨天才与它们一起工作。您是否可以保存未编制索引的值,然后稍后添加@Index注释?注释控制是否在保存时为属性编制索引;如果你添加注释,你必须重新保存任何相关的实体。是的,我现在明白我的错误了。我在想,因为超级,我不必在我的子类上添加@index,但现在我意识到这很愚蠢,因为我的子类上有需要索引的参数。。。我正在处理测试数据,所以我在理解问题后重新创建数据。感谢您的关注=)