Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1009

The propertyName in PropertyPath constructor doesn't follow the Javabeans Specification.

    XMLWordPrintable

    Details

      Description

      The propertyName changing as below in the PropertyPath constructor doesn't follow the JavaBeans Specification (8.8 Capitalization of inferred names.).

      // PropertyPath Code: lines 73:
      PropertyPath(String name, TypeInformation<?> owningType, List<PropertyPath> base) {
      ...
          String propertyName = name.matches(ALL_UPPERCASE) ? name : StringUtils.uncapitalize(name);
      ...
      }
      

      The code means the first capital letter is changed to lowercase when the name doesn't matche ALL_UPPERCASE.
      But the JavaBeans Specification says:

      JavaBeans Specification

      Thus when we extract a property or event name from the middle of an existing Java name, we
      normally convert the first character to lower case. However to support the occasional use of all
      upper-case names, we check if the first two characters of the name are both upper case and if
      so leave it alone
      . So for example,
      “FooBah” becomes “fooBah”
      “Z” becomes “z”
      “URL” becomes “URL”

      For example:
      When I have a property named [MCount] in a class, I use PropertyPath.from to get the property, I'll get the following exception, because the property name was changed to [mCount].

      PropertyPath property = PropertyPath.from("MCount", classType);
      

      Exception:
      java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [mCount] on this ManagedType [class]...

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            lin lin
            Last updater:
            lin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: