Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Update ?

 
Sudhakar Duraiswamy
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic