-->
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: Using <list>: problem with inverse
PostPosted: Thu Jan 04, 2007 12:01 am 
Contributor
Contributor

Joined: Tue May 30, 2006 1:25 am
Posts: 29
Hibernate version: SVN

This mapping work fine
Code:
   <class name="A" table="tabA">
      <id name="Id" type="Int32">
         <generator class="native" />
      </id>

      <list name="Elements" cascade="all">
         <key column="parentId" />
         <index column="childNum"/>
         <one-to-many class="B" />
      </list>
   </class>
   
   <class name="B" table="tabB">
      <id name="Id" type="Int32">
         <generator class="native" />
      </id>
      <property name="Name"/>
   </class>


This other don't work
Code:
   <class name="A" table="tabA">
      <id name="Id" type="Int32">
         <generator class="native" />
      </id>

      <list name="Elements" inverse="true" cascade="all">
         <key column="parentId" />
         <index column="childNum"/>
         <one-to-many class="B" />
      </list>
   </class>
   
   <class name="B" table="tabB">
      <id name="Id" type="Int32">
         <generator class="native" />
      </id>
      <many-to-one name="Parent" class="A" column="parentId"/>
      <property name="Name"/>
   </class>


The problem is that the childNum column is always NULL.
Is there some special issue for this beaviour ?

Thanks.

_________________
Fabio Maulo.


Top
 Profile  
 
 Post subject: Re: Using <list>: problem with inverse
PostPosted: Thu Jan 04, 2007 2:42 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
fabiomaulo wrote:
This other don't work
Code:
   <class name="A" table="tabA">
      <id name="Id" type="Int32">
         <generator class="native" />
      </id>

      <list name="Elements" inverse="true" cascade="all">
         <key column="parentId" />
         <index column="childNum"/>
         <one-to-many class="B" />
      </list>
   </class>
   
   <class name="B" table="tabB">
      <id name="Id" type="Int32">
         <generator class="native" />
      </id>
      <many-to-one name="Parent" class="A" column="parentId"/>
      <property name="Name"/>
   </class>


The problem is that the childNum column is always NULL.
Is there some special issue for this beaviour ?


Inverse means that the persisting is handled by the other end of association. So, the class "B" must save all values (including index) for list.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 3:31 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Indexed collections (lists and maps) cannot be mapped with inverse="true".


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 5:03 pm 
Newbie

Joined: Mon Nov 13, 2006 12:43 pm
Posts: 11
Location: US
Is there a workaround for this? Or, do I need to change the object model to not have bi-directional associations. It is kind of strange that NHibernate does not support this.

Thanks in advance!


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.