-->
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: Update Db from transient object
PostPosted: Sat Sep 23, 2006 9:14 am 
Newbie

Joined: Tue Apr 25, 2006 9:49 am
Posts: 9
Hi
I have question about updating DB from transient object.This is my flow:

1. Fetch Object from DB, present SOME of it's fields on web-tier for editing
--end of http and hibernte session
2.On post - create transient instance of object, call hibernate update.

What happens is that my transient object has null values for properties that i don't want the user to modify. And, of-couse, these null values are persisted to DB over "real" values.

What is the right and common solution for this flow?
Do i have to "manually" merge properties of transient object to pesistent(select befor update) instanse ?
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 1:26 pm 
Beginner
Beginner

Joined: Thu Jul 06, 2006 11:09 pm
Posts: 25
Transient objects means that they do not exist in the persistent layer (from the database). Hibernate expects it to have a null value for the Id. As my analysis is correct, and unless you used the session.evict(), Hibernate will never update a transient object, instead it creates a new persistent object.

Try LockMode NONE when you try to save the new values.

_________________
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 4:46 pm 
Newbie

Joined: Tue Apr 25, 2006 9:49 am
Posts: 9
Transient object is the the object that was created using constructor...


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.