小编use*_*057的帖子

子类属性上的 hql

我有一个类 A 和子类 B 和 C,它们具有不同的属性。我该怎么做: a from A a where ( a.class = B and a.specific-property-of-b = "y") or (a.class = C and a.specific-property-of-c ="z")

是否有可能让 hibernate 理解,当它是某个类的实例时,它可以访问它的特定属性,或者是不可能做这样的事情,我必须这样做:

a from A a where a.id in (select b.id from B b where b.specific-property-of-b = "y") 或 a.id in (select c.id from C c where c.specific- c 属性 = "z")

谢谢

polymorphism hibernate hql

6
推荐指数
1
解决办法
3110
查看次数

标签 统计

hibernate ×1

hql ×1

polymorphism ×1