-->
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: subclasses with same discriminator-value
PostPosted: Wed Jun 25, 2008 12:32 pm 
Newbie

Joined: Wed Jun 25, 2008 12:10 pm
Posts: 5
hi!

searched the web but didn't find anything that could help me.

here's the story (see xml on bottom):
i get many objects (for instance MegaSpeise) through a webservice, but the functionality is not enough so i have to extend these objects to gain my new objects (f.i. SpecialSpeise).

because i do not want to map all these files to my new objects (wrapper) i want to save the parentobjects to DB and "convert" it to concrete objects if needed.

i wrote a test where i added a MegaSpeise and then a SpecialSpeise.
after that i try to getAll() and logged the output.
i set the discriminator to the same values, and i guessed to get back one of the objects (MegaSpeise or SpecialSpeise) but still hibernate achieves it to differ between the MegaSpeise and the SpecialSpeise.
any suggestions? isn't the discriminator meant to determine which instance hibernate should create? (i also tried full classpath (f.i. both discr. set to entity.SpecialSpeise))

best wishes and thanks in advance

chris

<class name="entity.Speise">
<id name="id"><generator class="native" /></id>
<property name="..." />
<discriminator column="discriminator" type="string" length="1" />
<subclass name="entity.MegaSpeise" discriminator-value="S">
<property name="..." />
</subclass>
<subclass name="entity.SpecialSpeise" discriminator-value="S">
<property name="..." />
</subclass>
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 2:03 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 8:18 am
Posts: 31
You can not use same discriminator for two child classes because if you are saving it with same discriminators, then how hibernate will understand, which one is child A and which one is child B.

_________________
amer sohail


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.