You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ville Autio <au...@inbox.com> on 2012/10/18 11:58:37 UTC

[beanutils] BeanUtils.copyProperties and null values

I wonder what's the idea with this? Is this a bug or a feature? Using 1.8.3.

public class BeanUtilsTest {

    @Test
    public void testCopyProperties() throws Exception {

        SomeBean bean = new SomeBean();
        assertNull(bean.getId());

        BeanUtils.copyProperties(bean, new SomeBean());
        assertNull(bean.getId()); // Fails because bean.getId() returns 0.
    }

    public static class SomeBean {

        private Long id;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }
    }
}

____________________________________________________________
Publish your photos in seconds for FREE
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org