Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating single column using Hibernate

 
Raghusham Sankargal
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have login table with user and password. The password can be changed more than once.
In this way I want to update only that column.
Would you please how to do that ?

Thanksin advance,
Sham
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as the object is loaded,created,saved or queried by the session all the changes in the state will be persisted (i.e: automatic dirty checking by Hibernate) by the Hibernate when the session is flushed.
 
Raghusham Sankargal
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply.
Do you mean that the Hibernate makes sure it updates only those columns that are updated by the checking the row present in the database, takes the one that are new and then updates only them?

Kind Regards, Sham.
javascript:emoticon('');
 
xsunil kumar
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an element called "dynamic-update" that should be defined in your class definition in hibernate hbm files. By default its value will be false, it means that hibernate will generate update statement for all columns. If its value is true, then hibernate will generate update statement on run time and include only those colums whose values has been changed.

You can use dynamic-update=true. Below is the syntax for using this.

<class
name="ClassName" table="table" dynamic-update="true "

-Sunil
 
Vishwas Tyagi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In case of detached state, update(Object o) updates all columns of that table row.
If, i want to update only one column,then how to do that?

Suppose, i fire get method and hibernate returns me object say of Employee class, then i fire evict() on session.
now i update employee name, and calls update method .
In this case update method updates, all columns of the table(we can see query generated by hibernate using show_sql property).
i want to update only employee name and not rest of the columns , then how to do that?
Please Help
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic