• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BeanUtils and null-properties.

 
Grigory O. Ptashko
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I try to use BeanUtils from commons project. I want to copy properties from one bean to another. The problem I have is when the source bean has a java.lang.String property which is null and the target bean has property of java.lang.Long. Using BeanUtils.copyProperties(target, source) set the target's property to 0 (zero). But I do not need this. I need the property to stay null also as in the source bean.

Here is the sample code:

Source bean:


Target Bean:


And the code:



Gives the following output:



Any ideas?

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic