• 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 ?

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Disclaimer: I am a Hibernate newbee so please bear with me if my question sounds really stupid

Hi,
I am reading through hibernate docs and i really curious to know is it possible to perform an Update in hibernate
without loading the object (i know we could do this with HQL http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html#batch-direct , but i am just wondering if its possible with objects).

Because IMHO , i feel that its an over kill to load the object from DB to perform an update.

In other words we are performing a select and update query every time when we want to perform update action

Say if have a

Class A
|
--- string
---- int
---- List<class B> list


say to update the int , dont you think its an overkill to load the class A object which would inturn load the list of classB
 
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
First off - yes it is, you can do it directly with a HQL, just as you might in SQL.


Because IMHO , i feel that its an over kill to load the object from DB to perform an update.


This is more contentious. Hibernate offers caching and optimistic locking. You would be bypassing both to directly update via HQL, so you might be performing updates you don't need, and you will certainly cause lost updates.
reply
    Bookmark Topic Watch Topic
  • New Topic