• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate update when Object isn't modified

 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi Ranchers

Hibernate will not issue update statement when called update() when the object is not modified.
Means that when you don’t want to perform an update on an object , if the object isn’t modified .

Is this behaviour default or do i need to set any parameters for this ??

Please Help.
 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is this behaviour default or do i need to set any parameters for this ??


No, It's not default but you can ask hibernate to behave like that explicitly by setting dynamic-update=true. This is a class level attribute.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure it is with explicitly by setting dynamic-update=true

Because when i had gone through docs it said you need to set optimistic-lock attribute to dirty .

Anybody help to add a light on this topic please.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

RaviNada Kiran wrote:Are you sure it is with explicitly by setting dynamic-update=true


Did you try it?

RaviNada Kiran wrote:Because when i had gone through docs it said you need to set optimistic-lock attribute to dirty

Again did you try this?
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The dynamic-update would be fine updating the individual columns and optimistic lock code for the whole Object .
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, everybody:
i came cross this problem too! anyone has a good idea to solve it?
BTW, i use Struts2+Spring2+Hibernate3.
Spring takes charge of the Struts Action(scope="prototype") and Hibernate session/transaction.

I tried this: dynamic-update="true", but the setting is useless.

i've been seeking for long and got one solution:
load an object before you update it. (it means if you wanna modify an object, you'll have to load it for two times, and then saveOrUpdate it at last)...but i think it's not that good. Especially, we have to set all the properties by hand....oh, god. .what if the object is big enough as the earth?

i've been looking for a better way for 2 days...what makes me confused, what does the property "dynamic-update" use for???...

pardon my poor english..

best regards.

A reply from asia...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Especially, we have to set all the properties by hand....oh, god. .what if the object is big enough as the earth?


Doesn't loading it before updating fix this? Why do you need to set properties by hand? Just set those you are updating.
 
aran tam
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:


Especially, we have to set all the properties by hand....oh, god. .what if the object is big enough as the earth?


Doesn't loading it before updating fix this? Why do you need to set properties by hand? Just set those you are updating.


hi, Paul.
i use getHibernateTemplae().load(XXX.class, id) to load an object, then modify it in a form, and submit.
the property scope="prototype" in applicationContext.xml.
saveOrUpdate(obj). If there is not hidden property "id" in the form, "save(obj)" would be called. If there is a hidden property "id", "update(obj)" would be called, but those properties didn't need to change and i didn't modified is null....
so i have to load the object once again and set all the properties by hand, cuz i just need to modify some properties in different situation.

i am sorry for my poor english , i just can't express it out, though it might be just a very simple problem.
anyways, thank you, Paul
 
reply
    Bookmark Topic Watch Topic
  • New Topic