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.  [ 2 posts ] 
Author Message
 Post subject: CriteriaQuery / get "real" type
PostPosted: Mon Jul 03, 2006 4:41 pm 
Newbie

Joined: Mon Jul 03, 2006 4:33 pm
Posts: 1
Hi all,
I am quite new to Hibernate and cannot find an answer to this question:

I have a baseclass B and a class C which inherits from B and extends B. I have chosen to store these classes in one table using a discriminator.
I want to use a criteria query to retrieve all objects of class B or C which match certain conditions (these conditions do not require the object to be of class C). So I use B as CriteriaClass.
But when I get the result list, I get a list of instances of B (which seems clear, because I only queried for B).
How can I get at least the information whether my objects in the list have been saved as B or C?

Thanks a lot,
Martin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 6:26 pm 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
You might want to do some more validation to see if it downcasts for you properly. I think it might.

If I do:

Code:
session.Load(typeof(B), 1)


and then:
Code:
if(B is C)
  //do C stuff'


and C is a subclass (joined subclass in my case) then it will load all the way down to C even if I only asked for a B.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.