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