-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: HQL and polymorphism
PostPosted: Wed Sep 01, 2004 4:04 am 
Newbie

Joined: Wed Feb 25, 2004 5:28 pm
Posts: 15
In Hibernate reference chapter 10.6:
a query like " from eg.Cat as cat " returns not only Cat , it returns also subclasses of Cat.

and :

http://forum.hibernate.org/viewtopic.ph ... hism+query

How to use these subclasses that are returned base on polymorphism ? If type cast cannot be used in HQL.

There must be a way to use them, I will like to know "HOW".

I have a case here:
Class Parent
set = children : a collection of Child

Class Child

joined subclass Person

joined subclass Company

my incomplete query:

Select parent.key
from Parent parent
inner join fetch parent.children child
==>here, how to address Person that is returned by polymorphism ?
where parent.property1 = 100 and
child.property2 = 200 and
==>here, how to include only Person with property3 = 300

Please help and I am happy for any ideas and response.

/Kwan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 3:47 am 
Newbie

Joined: Wed Feb 25, 2004 5:28 pm
Posts: 15
It is me again.
Perhaps it is not possible to use the classed returned automatically based on polymorphism ?

Or am I not clear in the case description. I do not need a tailored fit answer, I need some pointers/ideas.

/Kwan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 7:20 am 
Newbie

Joined: Wed Feb 25, 2004 5:28 pm
Posts: 15
I found a solution:

Select parent.key
from Parent parent
inner join fetch parent.children child
==>here, how to address Person that is returned by polymorphism ?
Person person // get a fresh reference

where parent.property1 = 100 and
child.property2 = 200 and
==>here, how to include only Person with property3 = 300
child.id = person.id and
person.property3=100

I think so.

/Kwan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.