When I call saveOrUpdate, then the version field is updated even if no other fields have changed... Is there anyway to tell Hibernate not to update the version field as long as no changes have been made?
Regards,
BTJ
When I call saveOrUpdate, then the version field is updated even if no other fields have changed... Is there anyway to tell Hibernate not to update the version field as long as no changes have been made?
Regards,
BTJ
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
See http://forum.springframework.org/showthread.php?t=29032 and please, stop duping. Thanks.
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
Please use [ c o d e ] [ / c o d e ] tags
Hmmm.. This is in fact another question not related to that link..Originally Posted by Costin Leau
![]()
BTJ
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
I was/am reading the threads one after another and to me they seems to address the same problem. However to answer your different question - Hibernate doesn't do any optimization between the values and in fact it shouldn't - updating 1 with 1 is still an update and even though the information is the same, from the logical side the information has been changed.
You can extend Hibernate internals (though you'll have to get your hands dirty a bit) to do the optimization however note that this will add also a performance decrease since you'll have to read the information, compute the comparison and then do the update.
What if, in the meantime somebody else has updated the code?
Moreover, how are you going to do the comparison - you'll have to dehydrate objects from the database into the java world and rely on the object equals() which will fail or on toString() which again might yield unexpected results.
Basically, you have opened a can of worms...
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
Please use [ c o d e ] [ / c o d e ] tags
So when no fields have changed (and I have enabled dynamic-update), I can see that the only field that Hibernate is updating, is the version field... So when Hibernate knows that no fields have been changed, why does it update the version field? To me that seems unneccesary and can create conflicts later when another client is trying to do a real update (with changes) without reloading the values after the previous update of only the version field....
Or am I missing something?
BTJ
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
I assume there must be a reason for that behavior - have you looked at select-before-update? Anyway, I suggest you to investigate the Hibernate forums - they should provide faster and more accurate answers.
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
Please use [ c o d e ] [ / c o d e ] tags
I am also using select-before-update=true...
And I have also posted a message in the Hibernate forum but I never get any answers there.... I always get an answer in this forum and usually a good answer so....
BTJ
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"