【发布时间】:2015-03-03 03:46:56
【问题描述】:
我正在尝试通过 Reference 获取列表。
我的课是这样的:
- 在守护程序上运行的许可证,
- 许可证可以是 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;
}
如果我想查找在特定守护进程上工作的LicenseCountryCondition列表,我会这样做:
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());
}
我得到了很好的结果。
但是,当我尝试让 LicenseCountryCondition 列表在特定国家工作时,它不起作用:
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());
}
我可以得到这份清单吗? (我看到this但不是同一个问题)
感谢您的关注。
【问题讨论】:
标签: java google-app-engine filtering subclass objectify