-->
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: how to fetch subclass data in polymorphic queries
PostPosted: Tue Dec 12, 2006 6:05 am 
Beginner
Beginner

Joined: Wed Nov 15, 2006 4:25 am
Posts: 21
Hai Friends

I am working with Hibernate 3.0 and my DataBase is MS SQL 2000

I have a class called Contact and there are two classes which extends this class,these are called ContactAddress,ContactQualification.I am using table per subclass stratergy.

My problem is i want to retrieve all the information to a particular ID along with the subclasses data also.Can anyone help me

I have written the query like this

session.createQuery("from com.yash.hibernate.Contact as contact where contact.id = :fname").setParameter("fname", new Integer(2));

Is this right ? any changes i have to made. ?


Please help me i am in pressure to sovle this one.

Thanks in Advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 6:17 am 
Regular
Regular

Joined: Wed Mar 23, 2005 8:43 am
Posts: 105
Location: Moscow, Russia
Yes, with this query, you retrive data of the superclass along with data of one of the subclasses (if they shared same primary key).

_________________
Best Regards


Top
 Profile  
 
 Post subject: how to capture the superclass and subclass data ?
PostPosted: Wed Dec 13, 2006 12:38 am 
Beginner
Beginner

Joined: Wed Nov 15, 2006 4:25 am
Posts: 21
Thanks for your reply but can you please tell me how to capture the data produced by the above query and display it (I mean do I need to use Iterator if so can please you tell me ) .Yes i am have same PK .


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.