• 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

How does the update method work for Hibernate Session?

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Can anyone tell me how the update method works for Hibernate Session?

If I pass in a POJO (which has a corresponding table in the DB) does hibernate check which fields are different from the DB and only updates only the columns which have changed or does it to a blanket update of all columns in the table.

Thanks for any help.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe you'll get a blanket update. The update is really more of a differentiation from save. Essentially, you know that Hibernate will not create a new record in the database.

-Cameron McKenzie
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your entity is bound to the session, hibernate "knows" when it gets changed. By default every field is updated. But you can change that behaviour and use "dynamic update" which can save some time. E.g. when you have some large fields or blobs/clobs in your table.
I didn't check but (I think) if you want dynamic-update and the POJO isn't bound to the session hibernate does a SELECT and then creates an update.
 
reply
    Bookmark Topic Watch Topic
  • New Topic