You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Marco Janc (Jira)" <ji...@apache.org> on 2019/10/07 11:46:00 UTC

[jira] [Created] (BEANUTILS-526) copyProperty should instantiate nested properties

Marco Janc created BEANUTILS-526:
------------------------------------

             Summary: copyProperty should instantiate nested properties
                 Key: BEANUTILS-526
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-526
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: Bean / Property Utils
    Affects Versions: 1.9.4
            Reporter: Marco Janc


The function _BeanUtils.copyProperty(bean, name, value)_ shall instantiate nested properties before copying them.

 

*Example:*

 

 
{code:java}

{code}
*class Foo*
*{*
    *Bar bar;*
*}*

*class Bar*
*{*
    *int id;*
*}*

 

We now have an instance of _Foo_ where _bar_ property is null and call:

 
{code:java}
Foo foo = new Foo();
BeanUtils.copyProperty(foo, "bar.id", 3);
{code}
This will throw an exception currently.

 

*Workaround*

In my generic copy method, i instantiate all required nested properties before.

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)