-->
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: duplicate discriminator values
PostPosted: Thu Dec 08, 2005 12:47 am 
Newbie

Joined: Thu Oct 07, 2004 12:15 pm
Posts: 2
I noticed something a bit strange with hibernate today. I have a class hierarchy mapped to a single table using subclass mappings with discriminators. It seems that two of my subclasses inadvertently have the same discriminator value.

Off-hand I would have expected hibernate to complain about this on startup, when reading the mapping file, but it doesn't. It lets me persist both classes and writes the same discriminator in for instances of both classes. When I attempt to load these objects it always seems to instantiate instances of the last class to declare the duplicated discriminator value.

i.e. in Foo.hbm.xml there are subclass entries like:

<subclass name="ABC" discriminator-value="123"/>
<subclass name="DEF" discriminator-value="123"/>

Instances loaded from Foo are always of type DEF. Re-ordering the above two lines so that ABC appears last causes loaded instances to always be of type ABC.

Would it not make sense to detect cases of duplicated discriminators and fail to load mapping files containing them?

(this happens with hibernate 2.1.7)

Cheers,
Derek


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.