beanutils copy to ignore null properties

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

beanutils copy to ignore null properties

miro
I have Bean Test
with properties   A and B

An instance of  Test  TestA has value for A   and B is null.
another intance of Test  TestB  has value for B and A is null .
now  when I call copyProperties BeanUtils.copyProperties(TestA, TestB)
TestA
  property A will get null
and Propetrty B will be B

instead I want beanUtils to update TestA      just by copying non null properties is it possible ?

 
Reply | Threaded
Open this post in threaded view
|

Re: beanutils copy to ignore null properties

Niall Pemberton
On Mon, Oct 13, 2008 at 7:25 PM, miro <[hidden email]> wrote:

>
> I have Bean Test
> with properties   A and B
>
> An instance of  Test  TestA has value for A   and B is null.
> another intance of Test  TestB  has value for B and A is null .
> now  when I call copyProperties BeanUtils.copyProperties(TestA, TestB)
> TestA
>  property A will get null
> and Propetrty B will be B
>
> instead I want beanUtils to update TestA      just by copying non null
> properties is it possible ?

This isn't provided by BeanUtils, but you could use BeanUtils to build
this kind of *merge" functionality.

Niall

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]