-->
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: non-bidirectional One-to-many and generator
PostPosted: Mon Apr 02, 2007 11:02 am 
Newbie

Joined: Thu Mar 01, 2007 6:08 am
Posts: 3
Hi

hibernate 3.2

I'm having a one-to-many relationship, the parent's id is generated and the child is only referencing the paren'ts id :

Code:
<class name="my.Parent" table="PARENT_TABLE" mutable="false">
  <id name="id" type="long" column="PARENT_DB_ID">
    <generator class="sequence">
      <param name="sequence">PARENT_DB_ID</param>
    </generator>
  </id>
  <set name="children" cascade="all" inverse="true">
    <key column="PARENT_DB_ID"/>
    <one-to-many class="my.Child"/>
  </set>
</class>


Code:
<class name="my.Child" table="CHILD_TABLE" mutable="false">
  <id name="id" type="long" column="CHILD_DB_ID">
    <generator class="sequence">
      <param name="sequence">CHILD_DB_ID</param>
    </generator>
  </id>
  <property name="parent" column="PARENT_DB_ID" type="long"/>
</class>



My issue is that when I save the parent, hibernate don't set the Child.parent property with the generated parent's id, from the documentation (http://www.hibernate.org/209.html) this behavior seems straightforward when the child is referencing the parent through a many-to-one but for legacy reason I don't want to update the child class; is there a way to do this only using the mapping files ?

Thanks


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.