-->
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: Null checking when updating an object
PostPosted: Mon Jan 31, 2005 8:09 am 
Beginner
Beginner

Joined: Fri Sep 24, 2004 7:15 am
Posts: 40
Due to a problem I had (that is not worth explaining for the purpose of this question), I realized that no null checking is done when an object that already exists (persistent) is passed through the saveOrUpdate() function; however this checking is done when it must be saved (it's a new object).

Going over the code, there's a helper function named "checkNullability" that is called from the "doSave" method, but not the "doUpdate" method. So it results in the object being checked when it is going to be presisted for the very first time, but no checked when it is being persisted as a consequence of an update.

I suppose this behaviour has its explanation in the fact that, within an update operation, only valued fields are considered, i.e. if I don't want to change one column, just leave its correspondent field to null. But again this is not the reason, as Hibernate tries to save those nulls and, obviously, fails.

Could you please give me some detailed explanation about null treatment in Hibernate? If I just want to change one field of an object, do I have to leave the rest of the fields to null (don't think so), or do I have to load the object, previously to make the changes? I ask this last question, thinking about the situation where the object is automatically build upon the request parameters from the client explorer, but only a part of the object.

Looking forward to hearing your comments.

================
Enrique Medina


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.