rajneesh wrote:
Why hibernate saves every changed object in database at every flush? Why do I need a method like session.save(po) instead of just session.update();
You don't. Try calling no save() at all, you'll see updates happen anyway.
As said, you have to read some documentation about how Hibernate manages dirty checking. When retrieving an object with the session, you're not really using your POJO, but instead something that's called a dynamic proxy, which is actually a class that inherits your POJO and was generated at runtime (using cglib library for example).
If you don't want these automatic updates to happen, you should put your object in what's called a "detached" state. To achieve this, you can call session.evict(yourInstance) to prevent updates to happen if you don't call save() on it.
To sum up, by default, all instances retrieved from the session will behave this way.