Today, when using beanutils, we found that the original field is null when the copyproperties method is copied from long to long. After the result is copied, the target field is changed to 0, which is not the expected result, after searching online, you can use the converter to set the default conversion value when it is null.
Static {convertutils. register (New longconverter (null), long. class); convertutils. register (new vertex converter (null), short. class); convertutils. register (New integerconverter (null), integer. class); convertutils. register (New doubleconverter (null), double. class); convertutils. register (New bigdecimalconverter (null), bigdecimal. class );}
So I set the default conversion value of some commonly used numeric fields to null, and then use beanutils. if the copyproperties copy field, long, integer, and other fields are null, they will not be converted to 0 by default.