-->
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.  [ 3 posts ] 
Author Message
 Post subject: one-to-one mapping is not updated when parent is saved
PostPosted: Thu Nov 11, 2004 10:26 pm 
Newbie

Joined: Tue Sep 21, 2004 12:39 pm
Posts: 18
I have an object "Contract" that has a one-to-one mapping with an "Property". When I create a new Contract and save it, the Property object is also saved and persisted to the database.

However, when I update the Contract and Property objects and attempt to persist, the Contract object is updated, however the modified Property object is not updated.

I checked the SQL output, and there is an update entry for the Contract object.

TIA

Hibernate version:
2.1.6

Mapping documents:
Code:
  <class name="com.acme.Contract" >
    <meta attribute="class-description">
      Contract Rule Value
    </meta>

    <id name="id" type="integer">
      <meta attribute="scope-set">protected</meta>
      <generator class="native"/>
    </id>

    <one-to-one name="insuredProperty" class="com.acme.Property" cascade="save-update"/>
...


Code:
  <class name="com.acme.Property" >
    <meta attribute="class-description">
      Contract Property
    </meta>

    <id name="id" type="integer">
        <generator class="foreign">
            <param name="property">contract</param>
        </generator>
    </id>
   
    <one-to-one name="contract" class="com.acme.Contract" constrained="true"/>
...

_________________
David Launen


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2004 1:53 am 
Regular
Regular

Joined: Fri Nov 12, 2004 12:07 am
Posts: 57
Location: Beijing,China
why don't show your source code?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2004 9:36 am 
Newbie

Joined: Tue Sep 21, 2004 12:39 pm
Posts: 18
amjn wrote:
why don't show your source code?


I was going to, but I wanted to just make sure that the mappings were correct, because if the mappings are correct then I should be able to figure out the source.

Anyways, I figured out was wrong, I was using Hibernate.lock() instead of Hibernate.update().

Thanks.
David

_________________
David Launen


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