开发者

Can I use subclass properties in Hibernate Criterion Example?

I have a class-hierarchy:

Company <---- Customer
------        --------
string id     bool prospect
string name

Basically everything works fine (save and load).

What fails is this: I want to query all Customers which have prospect==true.

But, it seems like Hibernate is ignoring the prospect property of the subclass. I'm creating a Customer object and set prospect=t开发者_C百科rue , then I'm using this code

Example example = Example.create(exampleCustomerInstance);

When I look at the query (debug output) I see that there's no WHERE statement for prospect that's why all Customers are returned and not only those with prospect=true

As a workaround I've pulled up the prospect to the Company and now it works ... so my question:

is it impossible with Hibernate to query such subclass properties (if yes, why?)?

(I'm using Hibernate 3.6.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜