Compare and modify objects before and after:
Returns a Map with a different property named Key,value for a List obj1,obj2 the value of this property name, public static map<string,list<object>> equals ( Object Obj1,object obj2) throws Introspectionexception, Illegalaccessexception, IllegalArgumentException, invocationtargetexception{map<string,list<object>> map=new hashmap<string,list<object>> ( ); if (Obj1.getclass () ==obj2.getclass ()) {//Only two objects are of the same type have comparable Class clazz=obj1.getclass ();//Gets the property description of the object Propertydes Criptor[] Pds=introspector.getbeaninfo (clazz,object.class). Getpropertydescriptors (); for (PropertyDescriptor Pd:pds) {//Here is all the properties of String name=pd.getname ();//property name Method Readmethod=pd.getreadmethod ( );//get method//The Get method on Obj1 is equivalent to obtaining the Obj1 property value Object O1=readmethod.invoke (OBJ1);//The Get method on Obj2 is equivalent to getting the Obj2 property value Object O2 =readmethod.invoke (OBJ2); if (Pd.getpropertytype (). toString (). Equals ("Class Java.util.Date")) {o1= (dateutil.datetostring ((Date) O1, " YYYY-MM-DD HH:mm:ss ")); O2= (dateutil.datetostring (Date) O2, "YYYY-MM-DD HH:mm:ss ")); if (O1!=null&&o2!=null&&!o1.equals (O2)) {//compares the two values for equality, it can be placed in map list<object> list=new Arraylist<object> (); List.add (O1); List.add (O2); Map.put (name,list); }}} return map;}
Save the comparison result map with the log table.
The Java Web modifies the entity class and records the modifications.