-->
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: one-to-one: composition
PostPosted: Fri Apr 30, 2004 9:05 am 
Newbie

Joined: Fri Mar 26, 2004 7:02 am
Posts: 17
Hi,
I've the following 2 mappings (and classes) i,
Code:
<class name="ph.news.model.UtenteBase" table="ph_diadoracommunity_users">
      <id name="id" type="int" column="u_id" unsaved-value="0">
         <generator class="identity"/>
      </id>
      
      
      
      <property name="name"/>
      <one-to-one name="datiLivello1" class="ph.news.model.DatiLivello1" cascade="all"/>
      
   </class>
   <class name="ph.news.model.DatiLivello1" table="ph_diadoracommunity_users_lv1">
      <id column="u_id" type="int">
         <generator class="foreign">
            <param name="property">utenteBase</param>
         </generator>
      </id>
      
      <one-to-one name="utenteBase" class="ph.news.model.UtenteBase" constrained="true"/>
      
      <property name="city"/>
      
   
   </class>



f I manually insert data into DB all works: when I load a ph.news.model.UtenteBase by primary Id the object has datiLivello1 property loaded BUT if I modify the ph.news.model.UtenteBase object an then I perform:
Code:
sess = this.getSession();
          
            tx = sess.beginTransaction();
         
            sess.update(u);
            sess.flush();

I see that hibernate try to make an INSERT of datiLivello1 data AND NOT an update so there is an exception.
Do you know why?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 9:40 am 
Newbie

Joined: Fri Mar 26, 2004 7:02 am
Posts: 17
SOLVED!!!

I've added id property To ph.news.model.DatiLivello1 class:

From:

<id column="u_id" type="int">

To
<id name="id" column="u_id" type="int">


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.