-->
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: 1-to-1 not saving dependent object changes.
PostPosted: Tue Jun 29, 2004 11:33 am 
Regular
Regular

Joined: Mon Sep 29, 2003 9:39 am
Posts: 67
Code:
session.saveOrUpdate(review);                   //tried save and update sep.
session.saveOrUpdate(review.getState());   //added out of desperation.
session.flush();
session.connection().commit();

Mapping:
Code:
<class name="Review" table="review">
<id name="id" type="long" column="review_id">
  <generator class="identity"/>
</id>
<one-to-one name="state" class="ReviewState" cascade="all"/>
...
<class name = "ReviewState" table="review_state">
<id name="id" type="long" column="review_id">
  <generator class="foreign">
   <param name="property">review</param>
  </generator>
</id>
<one-to-one name="review" class="Review" constrained="true"/>
...

The Review is created with an initialized ReviewState object, but the
ReviewState object's Review is null (and resulted in an exception).
Adding this weirdness at creation fixed that:
Code:
//associate the review with the state.
review.getState().setReview(review);

Now, when the review is changed and saved, changes persist, but when
the ReviewState is changed, changed do not. show_sql doesn't generate any SQL. If a review is created or deleted, the corresponding reviewstate is inserted or deleted. I've set breakpoints and stepped thru to ensure that the expected values are indeed what is expected, and they are. On load, the value is 0, right before save and after the value is 3, but in the
db, the value remains 0. What do I need to change to make this persist
the changes - as the code shows, I've tired saving the ReviewState explicitly, and nothing.


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.