-->
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: Collection of superclass problem
PostPosted: Tue Apr 27, 2010 5:20 am 
Newbie

Joined: Wed Mar 03, 2010 8:27 pm
Posts: 9
Location: Russia, Perm
Hi!
I've got mapping like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class discriminator-value="0" name="Testee" table="testee">
    <id column="id" name="id" type="integer">
      <generator class="increment"/>
    </id>
    <discriminator column="type_id"/>
    <property column="create_date" name="createDate" type="date"/>
  </class>
</hibernate-mapping>

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <subclass extends="Testee" name="Testee2" discriminator-value="1">
    <property column="email" name="email" type="string"/>
  </subclass>
</hibernate-mapping>

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="Attempt" table="attempts">
    <id column="id" name="id" type="integer">
      <generator class="increment"/>
    </id>
    <many-to-one class="Testee" column="testee_id" name="testee"/>
  </class>
</hibernate-mapping>

So, when i'm trying to get Testee2 (according to discriminator) object from Attempt object, hiberhate fetches Testee object that I can't cast to Testee2.

How can I save inheritance mapping and fetch object of correct class?


Top
 Profile  
 
 Post subject: Re: Collection of superclass problem
PostPosted: Tue Apr 27, 2010 6:05 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Seems like you are affected by a limitation in the proxy system that is described here: http://docs.jboss.org/hibernate/stable/ ... ng-proxies


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.