-->
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: Inheritance - Recovering child reference instead superclass
PostPosted: Tue Aug 26, 2014 2:42 pm 
Newbie

Joined: Tue Aug 26, 2014 2:25 pm
Posts: 2
Hibernate people! Hello everyone!

I need something I think, it's really possible but I don't know if JPA/Hibernate can provide me.

I have this hierarchy:
Code:
Class A{}
Class B extends A{}
Class C extends A{}


I would like to query in table A but returning subclass objects as references, even if the subclass table (B or C) does not have records. This way:

Code:
List<A> list = session.findAll(A.class); // I need instances of B or C class. I can provide this type as a parameter.
for(A record : list){
  B b = (B) record;
}


I would like this cast be possible.

Was I clear?

Thanks all!


Top
 Profile  
 
 Post subject: Re: Inheritance - Recovering child reference instead superclass
PostPosted: Thu Aug 28, 2014 5:04 pm 
Newbie

Joined: Tue Aug 26, 2014 2:25 pm
Posts: 2
Anyone?


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.