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

NullPointerException when combining JPA Entities with Embedded attributes and composite key in IdClass

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • V2 2.0.12
    • None
    • odata2-core
    • None

    Description

      The JPA Processor Core crashes with a null pointer exception when an Entity with the following conditions is parsed:

      • The Entity has multiple Id columns (composite key)
      • This leads to the case that the JPAEdmEntityType.getIdType() returns null.
      • The Entity also has at least one Embedded attribute class
      • This leads to the following coding in org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmProperty.build

      if (isBuildModeComplexType == false && entityTypeView.getJPAEntityType().getIdType().getJavaType().equals(currentAttribute.getJavaType())) {

      https://github.com/apache/olingo-odata2/blob/master/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmProperty.java#L238

      As getIdType() returns null this inevitably leads to a NullPointerException.

      Workaround:

      By using a JPAEDMMappingModel we can ignore any Embedded attributes in our Entities.

      This currently works for us, as we do not need to share these properties in OData, but it is not a permanent solution.

      Note:

      We do not quite understand why getIdType returns null - but we also cannot find any other place where it is used. It is possible that the composite key is not relevant, and instead getIdType does not work as expected.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            robin.mueller-cajar Robin Müller-Cajar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: