[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: [jira] [Commented] (BEANUTILS-443) PropertyUtils.setProperty(...) cannot find the Setter method if r
From: "Oliver Heger (JIRA)" <jira () apache ! org>
Date: 2013-11-30 16:46:35
Message-ID: JIRA.12658248.1374065229503.49495.1385829995159 () arcas
[Download RAW message or body]
[ https://issues.apache.org/jira/browse/BEANUTILS-443?page=com.atlassian.jira.plug \
in.system.issuetabpanels:comment-tabpanel&focusedCommentId=13835777#comment-13835777 \
]
Oliver Heger commented on BEANUTILS-443:
----------------------------------------
If I understand this report and the provided code examples correctly, the involved \
classes violate the Java Beans specification which is pretty strict regarding the \
conventions for get and set methods for valid bean properties.
However, you may have a look at BEANUTILS-425 and BEANUTILS-428 which add a mechanism \
to extend the introspection mechanism used by BeanUtils. By customizing this \
mechanism you should be able to correctly handle your entity classes.
> PropertyUtils.setProperty(...) cannot find the Setter method if returnValue doesn't \
> exact match the interface return value.
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: BEANUTILS-443
> URL: https://issues.apache.org/jira/browse/BEANUTILS-443
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: Bean / Property Utils
> Affects Versions: 1.8.3
> Environment: at least Java 1.6.0_33 on ubuntu
> Reporter: Harald Brabenetz
> Priority: Critical
>
> Here is My testClass:
> {code:title=PropertyUtilsSetValueUTest.java|borderStyle=solid}
> import org.apache.commons.beanutils.PropertyUtils;
> import org.junit.Test;
> public class PropertyUtilsSetValueUTest {
> @Test
> public void testSetProperty() throws Exception {
> final MyEntity entity = new MyEntity();
> // fist set value manual
> final OtherEntity otherEntity = new OtherEntity();
> entity.setOtherEntity(otherEntity);
> // second set value with PropertyUtils
> PropertyUtils.setProperty(entity, "otherEntity", otherEntity);
> // => java.lang.NoSuchMethodException: Property 'otherEntity' has no setter method \
> in class '... MyEntity' }
> public static class MyEntity implements MyEntityInterface {
> private OtherEntity otherEntity;
> @Override
> public OtherEntity getOtherEntity() {
> return this.otherEntity;
> }
> public void setOtherEntity(final OtherEntity otherEntity) {
> this.otherEntity = otherEntity;
> }
> }
> public static class OtherEntity implements OtherEntityInterface {
> }
> public static interface MyEntityInterface {
> OtherEntityInterface getOtherEntity();
> }
> public static interface OtherEntityInterface {
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.1#6144)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic