-->
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: How to update only what change and is not null ?
PostPosted: Thu Jun 12, 2008 9:23 am 
Newbie

Joined: Wed Feb 13, 2008 10:28 am
Posts: 5
So, how I can update only what changes and is not null ? In the case of a not null field, to normal fields the update works fine...

For an example, I have one entity...

Client: code(key), name, street,number,dateSave(the date that this client is saved in the system...)

So the dateSave field is saved only in the SAVE method, and it never change. But when I try to perform one Session.update call on a client row, I get the follow error.

Code:
org.hibernate.PropertyValueException: not-null property references a null or transient value: Client.dateSave


The work arround that I use to perform this behavior is to programaticly create one UPDATE HQL Query to update my registry. This works fine but it seems that it is not the best aproach =/

How can I do this with a simple call to Session.update ? Exists any mapping property that I can set to perform this behavior ?

Thanks in advance.
Rodrigo Kerkhoff


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 4:54 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
What you need to do is use Hibernate to load the entity from the database into your program. Update that loaded entity, and then commit your transaction. The data will be updated without worrying about any null values.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 15, 2008 8:13 am 
Newbie

Joined: Wed Feb 13, 2008 10:28 am
Posts: 5
This is the unique work arround for this problem ?

The system that I´m developing will be accessed in all country, so, this 'SELECT' before update would be a performance problem I think... am I wrong ?

Because the system will be acessed by +- 2000 peoples simultaneously....

Off course, this peoples doesnt go to perform updates like this every time....

I just want to know if this is the unique solution that I have....

Thanks for the reply..

Rodrigo Kerkhoff


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.