You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "K Lamb (JIRA)" <ji...@apache.org> on 2009/11/25 02:12:39 UTC

[jira] Created: (BEANUTILS-369) using PropertyUtilsBean getProperty method does not find attributes in a class when names have a single lower case character

using PropertyUtilsBean getProperty method does not find attributes in a class when names have a single lower case character
----------------------------------------------------------------------------------------------------------------------------

                 Key: BEANUTILS-369
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-369
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: Bean / Property Utils
    Affects Versions: 1.8.2
         Environment: windows xp
            Reporter: K Lamb


Using a class that has an attribute named like aRatedCd with get/set methods of getARatedCd() and setARatedCd(String) causes the PropertyDescriptor info to become name=ARatedCd. the read and write methods are found and have the above names. However because the name in the PropertyDescriptor has changed from aRatedCd to ARatedCd using the getProperty(obj, "aRatedCd") method thros a NoSuchMethodException.

If the aRatedCd attribute name is changed to something like aaRatedCd and the methods are also changed to getAaRatedCd() and setAaRatedCd(String) then the NoSuchMethodException is not thrown when using the getProperty(obj, "aaRatedCd") call.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (BEANUTILS-369) using PropertyUtilsBean getProperty method does not find attributes in a class when names have a single lower case character

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEANUTILS-369?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton resolved BEANUTILS-369.
---------------------------------------

    Resolution: Invalid

BeanUtils operates according to the Java Beans Specification:

    http://java.sun.com/javase/technologies/desktop/javabeans/docs/spec.html


There is no capitalization/decapitalization done in BeanUtils - it uses the Introspector to find the properties of a bean:

    http://java.sun.com/j2se/1.5.0/docs/api/java/beans/Introspector.html

Whatever you call the instance variable is irrelevant - it works out the properties of a bean from the get/set methods you have. The Java Bean Specification states in section "8.8 Capitalization of inferred names" that when the first character is converted to lowercase unless the first two characters are both uppercase then the property name is "unchanged".

So when you have a getter method named "getARatedCd" this is translated into property name "ARatedCd" and not "aRatedCd". 

So to resolve your issue you have two choices:

    * use property name "ARatedCd" instead or
    *  change you method names to "getaRatedCd" and "setaRatedCd"

I have added a test case to demonstrate this:

    http://svn.apache.org/repos/asf/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira369TestCase.java

Closing as INVALID

> using PropertyUtilsBean getProperty method does not find attributes in a class when names have a single lower case character
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: BEANUTILS-369
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-369
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.2
>         Environment: windows xp
>            Reporter: K Lamb
>
> Using a class that has an attribute named like aRatedCd with get/set methods of getARatedCd() and setARatedCd(String) causes the PropertyDescriptor info to become name=ARatedCd. the read and write methods are found and have the above names. However because the name in the PropertyDescriptor has changed from aRatedCd to ARatedCd using the getProperty(obj, "aRatedCd") method thros a NoSuchMethodException.
> If the aRatedCd attribute name is changed to something like aaRatedCd and the methods are also changed to getAaRatedCd() and setAaRatedCd(String) then the NoSuchMethodException is not thrown when using the getProperty(obj, "aaRatedCd") call.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-369) using PropertyUtilsBean getProperty method does not find attributes in a class when names have a single lower case character

Posted by "K Lamb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12782443#action_12782443 ] 

K Lamb commented on BEANUTILS-369:
----------------------------------

Thanks for the quick answer. Unfortunately for us the classes in question are being generated by the JAXB tooling in 1 of the IBM IDE tools. The get/set methods are being created/named by the JAXB xjc tool from xsd files. The xsd files have the aRatedCd attribute name.

Thanks again for the quick turn-around and the explanation on how the BeanUtils component is deriving the PropertyDescriptor info.



Ken Lamb
Solution Architect
Travelers BI Small Commercial Systems
443.353.1565
THE TRAVELERS INDEMNITY COMPANY-CONFIDENTIAL & PROPRIETARY INFORMATION, NOT FOR DISTRIBUTION



> using PropertyUtilsBean getProperty method does not find attributes in a class when names have a single lower case character
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: BEANUTILS-369
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-369
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.2
>         Environment: windows xp
>            Reporter: K Lamb
>
> Using a class that has an attribute named like aRatedCd with get/set methods of getARatedCd() and setARatedCd(String) causes the PropertyDescriptor info to become name=ARatedCd. the read and write methods are found and have the above names. However because the name in the PropertyDescriptor has changed from aRatedCd to ARatedCd using the getProperty(obj, "aRatedCd") method thros a NoSuchMethodException.
> If the aRatedCd attribute name is changed to something like aaRatedCd and the methods are also changed to getAaRatedCd() and setAaRatedCd(String) then the NoSuchMethodException is not thrown when using the getProperty(obj, "aaRatedCd") call.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.