The Java Web modifies the entity class and records the modifications.

Source: Internet
Author: User
Tags java web

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.