This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes BeanUtils and null-properties. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "BeanUtils and null-properties." Watch "BeanUtils and null-properties." New topic
Author

BeanUtils and null-properties.

Grigory O. Ptashko
Greenhorn

Joined: Jan 26, 2006
Posts: 16
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.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: BeanUtils and null-properties.
 
jQuery in Action, 3rd edition