is Dirty : Does this Session contain any changes which must be synchronised with the database?
Student student = (Student)session.get(Student.class,"1");
//student.setStudentName("Venu");
if(session.isDirty()){
System.out.println(".Sync is Required");
}else{
System.out.println(".Sync is not Required");
}
If the changes are there for the obj (student) then it returns "true" and if changes are not there then it returns "false".
In the above code sync is not requires because object is not modified and if we uncomment the code then sync is required because session and Database values are not same.
This type of checking is automatically done by Hibernate ,we call it as Dirty checking..
Student student = (Student)session.get(Student.class,"1");
//student.setStudentName("Venu");
if(session.isDirty()){
System.out.println(".Sync is Required");
}else{
System.out.println(".Sync is not Required");
}
If the changes are there for the obj (student) then it returns "true" and if changes are not there then it returns "false".
In the above code sync is not requires because object is not modified and if we uncomment the code then sync is required because session and Database values are not same.
This type of checking is automatically done by Hibernate ,we call it as Dirty checking..