-->
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: select from 2 classes that the one inherits from the other
PostPosted: Mon Dec 11, 2006 1:04 pm 
Newbie

Joined: Wed Nov 15, 2006 4:47 am
Posts: 11
Hi! I am i newbie and i have a problem with this (which honestly seems quite simple, but still...!):

Concerning the reference's example of the Cat and the DomesticCat subclass,
I want to retrieve with one query (for training purposes) all of the Cats (including the Domestic). But i want to have in the results the "name" property of the Domestic Cats as well, of course only for the Domestic Cats.

I have had several problems trying to do that, including having to retrieve the DomesticCats twice, some casting problems and several NullPointerExceptions when trying with joins(which also have to do with casting).

Could you please point out a solution, or a direction towards it.
I know I am just stuck, but it's for good!

For those who dont remember the Cat example:

class Cat{
//data members

//geters and setters
}

class DomestcCat extends Cat{
String name;
getName(),setName
}


The mapping:

<class name="Cat" table="cats" discriminator-value="C">
<discriminator column="subclass" type="character"/>
....
....
<subclass name="DomesticCat" discriminator-value="D">
<property name="name" type="string"/>
</subclass>
</class>


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.