本文介绍了客观化:通过某种类型的参考(或关键)进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有这些类: @Entity class MyEntity {
@Id String id;
@Index Ref<?> REF;
@Entity class Kind2 {
...
}
我可以查询所有 MyEntitiy
对象,其中 ref
引用任何 Kind2
?如果是这样,怎么样?
解决方案
Moshe的答案确实是正确的。但是,您可以在技术上通过对密钥执行不等式查询来破解某些有用的东西。即,> = KEY('Kind2',0)
和 。如果你的实体有父母,这会变得更加复杂。
我不会推荐你这样做,除非你真的知道你在做什么。
Say I have these classes:
@Entity class MyEntity {
@Id String id;
@Index Ref<?> ref;
}
@Entity class Kind2 {
...
}
Can I query for all MyEntitiy
objects where ref
refers to any instance of Kind2
? If so, how?
解决方案
Moshe's answer is really the right one. However, you can technically hack something that works by performing inequality queries on the key. Ie, >= KEY('Kind2', 0)
and <= KEY('Kind2', MAX_LONG)
. This gets significantly more complicated if your entities have parents.
I wouldn't recommend doing this unless you really know what you are doing.
这篇关于客观化:通过某种类型的参考(或关键)进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!