Oliver created OLINGO-1616:
------------------------------
Summary: Primary key corresponding to derived entity specified by
IdClass not recognized
Key: OLINGO-1616
URL: https://issues.apache.org/jira/browse/OLINGO-1616
Project: Olingo
Issue Type: Bug
Components: odata2-core, odata2-jpa
Affects Versions: V2 2.0.13
Reporter: Oliver
Example model slightly modified from JPA manual:
{code:java}
@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;
...
}{code}
Results in NPE:
{code:java}
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]
{code}
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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)