You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Robin Müller-Cajar (Jira)" <ji...@apache.org> on 2023/06/19 16:02:00 UTC

[jira] [Created] (OLINGO-1601) NullPointerException when combining JPA Entities with Embedded attributes and composite key in IdClass

Robin Müller-Cajar created OLINGO-1601:
------------------------------------------

             Summary: NullPointerException when combining JPA Entities with Embedded attributes and composite key in IdClass
                 Key: OLINGO-1601
                 URL: https://issues.apache.org/jira/browse/OLINGO-1601
             Project: Olingo
          Issue Type: Bug
          Components: odata2-core
    Affects Versions: V2 2.0.12
            Reporter: Robin Müller-Cajar


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.



 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)