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.  [ 4 posts ] 
Author Message
 Post subject: Discriminators not used when pulling subclasses?
PostPosted: Wed Jun 16, 2004 3:46 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 11:01 pm
Posts: 23
I'm having a problem with the <subclass> mapping. I have something like this:

Code:
<class name="Base" table="base" discriminator-value="null">
  <subclass name="A" discriminator-value="1">
  </subclass>
  <subclass name="B" discriminator-value="2">
  </subclass>
</class>

<class name="Foo">
  <set name="stuff" table="base">
    <one-to-many class="A" />
  </set>
</class>



My problem is that when I try to load Foo, the set of stuff that gets loaded is of both class A and B. The SQL that gets generated does not use the discriminator-value at all. Is this the way it's supposed to work?


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 3:52 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 10:20 am
Posts: 77
Shouldn't your one-to-many mapping from Foo be to the Base class, rather than A?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 4:15 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 10:20 am
Posts: 77
Ok, apologies, just re-read your problem, so ignore my first answer.

It doesn't need to use the descriminator as it knows what type of class it is retrieving - it only needs to query against the descriminator if it doesn't know the exact class type that it's retrieving. i.e. if you'd followed my first answer, then it would use the descriminator to work out whether the class type was A or B within the Set.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 4:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is a known issue. Use the where attribute of the set element to workaround.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.