Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-120

JPA Entity parser fails if there is a boolean property with "is" prefixed getter method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • V2 1.0.0
    • V2 1.1.0
    • odata2-jpa
    • None

    Description

      I am having JPA Model exposed as OData using the framework.
      One of the entities contains boolean propery called "active" with pair of generated "setter/getter" methods - "isActive/setActive".

      According to the JavaBeans specification section 8.3.2:
      Boolean properties
      In addition, for boolean properties, we allow a getter method to match the pattern:

      public boolean is<PropertyName>();

      This "isPropertyName" method may be provided instead of a "get<PropertyName>" method, or it may be provided in addition to a "get<PropertyName>" method. In either case, if the is<PropertyName> method is present for a boolean property then we will use the "is<PropertyName>" method to read the property value. An example boolean property might be:

      public boolean isMarsupial(); public void setMarsupial(boolean m);

      So according to the spec it should be perfectly fine.
      However i am getting "Null Pointer" exceptions when trying to navigate to this entity.

      While debugging i found out that the "get" prefix is hard coded in JPAEntityParser.
      See line 150:
      if (!jpaEntityAccessMap.containsKey(jpaEntityAccessKey))

      { jpaEntityAccessMap.put(jpaEntityAccessKey, getAccessModifiers(jpaEntity, structuralType, ACCESS_MODIFIER_GET)); }

      Which goes to getAccessModifiers method (line 312) and tries to find "getActive" method and throws NoSuchMethod Exception on line 322.

      accessModifierMap.put(
      propertyName,
      jpaEntity.getClass().getMethod(name,
      (Class<?>[]) null));

      My best guess is that boolean properties should be detected .. or JAVA beans introspector could be used instead of proprietary implementation.

      Attachments

        Activity

          People

            anirbanroy Anirban Roy
            chavdarb Chavdar Baikov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: