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

Primary key corresponding to derived entity specified by IdClass not recognized

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • V2 2.0.13
    • None
    • odata2-core, odata2-jpa
    • None

    Description

      Example model slightly modified from JPA manual:

      @Entity
      public class Employee {
        @Id long empId;
        ...
      }
      
      @Entity
      public class Department {
        @Id String depId;
        ...
      }
      
      public class DependentId {
        String dept; // matches name of @Id attribute and type of Department PK
        long  emp; // matches name of @Id attribute and type of Employee PK
      }
      
      @Entity
      @IdClass(DependentId.class)
      public class Dependent {
        @Id @ManyToOne Department dept;
        // id attribute mapped by join column default
        @Id @ManyToOne Employee emp;
        ...
      }

      Results in NPE:

      java.lang.NullPointerException: Cannot invoke "org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmKeyView.getEdmKey()" because "keyView" is null
              at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmEntityType$JPAEdmEntityTypeBuilder.build(JPAEdmEntityType.java:139) ~[olingo-odata2-jpa-processor-core-2.0.13.jar!/:2.0.13]
              at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmEntitySet$JPAEdmEntitySetBuilder.build(JPAEdmEntitySet.java:89) ~[olingo-odata2-jpa-processor-core-2.0.13.jar!/:2.0.13]
              at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmEntityContainer$JPAEdmEntityContainerBuilder.build(JPAEdmEntityContainer.java:117) ~[olingo-odata2-jpa-processor-core-2.0.13.jar!/:2.0.13]
              at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmSchema$JPAEdmSchemaBuilder.build(JPAEdmSchema.java:120) ~[olingo-odata2-jpa-processor-core-2.0.13.jar!/:2.0.13]
              at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmModel$JPAEdmModelBuilder.build(JPAEdmModel.java:61) ~[olingo-odata2-jpa-processor-core-2.0.13.jar!/:2.0.13]
              at org.apache.olingo.odata2.jpa.processor.core.edm.ODataJPAEdmProvider.getSchemas(ODataJPAEdmProvider.java:284) ~[olingo-odata2-jpa-processor-core-2.0.13.jar!/:2.0.13]
              at org.apache.olingo.odata2.core.edm.provider.EdmServiceMetadataImplProv.getDataServiceVersion(EdmServiceMetadataImplProv.java:108) ~[olingo-odata2-core-2.0.13.jar!/:2.0.13]
              at org.apache.olingo.odata2.api.processor.ODataSingleProcessor.readMetadata(ODataSingleProcessor.java:381) ~[olingo-odata2-api-2.0.13.jar!/:2.0.13]
      

      Seems that when processing the Dependent Entity the primary keys are not recognized as keys because they are located on an association, so building the key view results in the NPE while no other primary keys are present.

      Attachments

        Activity

          People

            Unassigned Unassigned
            obuhc Oliver
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: