With the Hibernate cache, basically, when you open a session, and start a transaction, the Hibernate Session keeps a local copy of the Java object (the entity), and makes changes to that local copy. Since this all happens within a transaction, and the database is locked (?), then just manipulating the local object makes more sense than going back and forth to the database. However, once the HibernateSession's transaction is committed, the final state of the POJO is persisted to the database.
In web applications, a simple way to keep a session open is to use a ServletFilter and open a Hibernate Session and start a transaction before the filter chain, and then commit the transaction after the filter chain has completed. With that, the session lasts the duration of the request, and you avoid LazyInitializationExceptions in your JSP pages and Servlets. Google for Open Session in View pattern for more details.
For more information on opening and closing sessions, take a look at the following tutorial on How Hibernate Works:
http://www.thebookonhibernate.com/Hiber ... rnateworks