permaculture playing cards*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "BeanUtils and null-properties." Watch "BeanUtils and null-properties." New topic

BeanUtils and null-properties.

Grigory O. Ptashko

Joined: Jan 26, 2006
Posts: 16

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?

I agree. Here's the link:
subject: BeanUtils and null-properties.
Similar Threads
Problem -EJB3+JPA+HIbernate
[Hibernate] Join without FK Relationship using Criteria
Problem in generating the Primary Key using a Sequence
GenerationType.AUTO Not Working
Encapsulation ?