-->
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: zero length string vs. null value causes dirty value update
PostPosted: Fri Dec 16, 2005 9:44 am 
Newbie

Joined: Fri Dec 16, 2005 9:28 am
Posts: 2
If a column value is null in the database, the object value gets set to null when the object is initialized.

I am using a JSF dataTable to update records via an html form submit.

The problem I have is that JSF sets the null value to a zero length string, which causes Hibernate to see the change from a null value to a zero length string as a property change. Therefore the object is marked as dirty and the database gets updated.

Is there some kind of property I can set in the mapping file to treat empty strings the same as null to avoid unnecessary updates?

My current workaround if to do the check in each setter method of the object and set the value to null if the string is empty. This is rather tedious. I am looking for a automated way to acomplish this.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 10:09 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
probably custom string type can help http://www.hibernate.org/hib_docs/v3/re ... pes-custom
see "isDirty"


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.