-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Inheritance
PostPosted: Thu Aug 05, 2010 6:21 pm 
Newbie

Joined: Fri Jul 02, 2010 11:11 am
Posts: 4
Hi,

Is there a way for me to get a collection of object from a query? My problem right now is I want to return a list of object from a table called Activity, which have objects extending it with inheritance. I want to be able to cast my result into specific object that is extending it. I could query the entire activity record but there doesn't appear to be a way for me to know if it is a WORK activity or a FUN activity. Is there a way for me to get the DiscriminatorValue since it doesn't have any getter. Reason is I want to return a collection of all the work and fun activity without querying only fun activity. This is only a short example but my code has 8 more different type of activity.

Thank you.


@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "activityType", discriminatorType = DiscriminatorType.STRING)
public class Activity

@Entity
@DiscriminatorValue("WORK")
public class Work extends Activity {

@Entity
@DiscriminatorValue("FUN")
public class Fun extends Activity {


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

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.