Dirty checking in Hibernate.


In this it checks that the object state is changed or not. If it is changed, it automatically calls the update method. If commit method is called, In such case state will be updated automatically.
This process is called automatic dirty checking.

SessionFactory objSessionFactory = HibernateUtil.getSessionFactory();
Session objSession = objSessionFactory.openSession();
Transaction objTx = objSession.beginTransaction();
Employee objEmp = (Employee) objSession.load(Employee.class, new Long(101));
objEmp.setName("Rahul");
objTx.comit();
objSession.close();


In this process we have changed employee object and commit the transaction, so it will be automatically updated.