开发者

Hibernate Criteria: inheritence: Get a list of only the root class entities

开发者 https://www.devze.com 2023-01-07 02:20 出处:网络
Assume i have: @Inheritance(strategy = InheritanceType.JOINED) public cla开发者_开发知识库ss Child extends Parent{

Assume i have:

@Inheritance(strategy = InheritanceType.JOINED)
public cla开发者_开发知识库ss Child extends Parent{
}

How can i do a selection of only the instances saved as a Parent, not as a Child.

Thank you


Take a look at the bottom of section 14.9 of the Hibernate documentation:

The special property class accesses the discriminator value of an instance in the case of polymorphic persistence. A Java class name embedded in the where clause will be translated to its discriminator value.

from Cat cat where cat.class = DomesticCat

So I believe in your case you could use the HQL constraint ... where class=Parent to filter out the instances of Child.

0

精彩评论

暂无评论...
验证码 换一张
取 消