SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
122 stars 76 forks source link

NPE during the NavigationProperties build #214

Closed Valeri-Velev closed 8 months ago

Valeri-Velev commented 1 year ago

I did the same as this example https://github.wdf.sap.corp/odata-jpa/odata-v4-jpa-spring-example but now when I try to reach my metadata I receive only this:

{ "@odata.context": "$metadata", "value": [] }

Could you help me?

Best Regards, Valeri

Valeri-Velev commented 1 year ago

Update:

Currently, only enum classes are visible in the response

Valeri-Velev commented 1 year ago

Update #2:

when I call this '/v1' endpoint which should show all my entities I get a response this exception with status code 500 { "error": { "code": null, "message": "Cannot invoke \"javax.persistence.OneToOne.mappedBy()\" because the return value of \"java.lang.reflect.AnnotatedElement.getAnnotation(java.lang.Class)\" is null" } }

And this happens only on the 1st invocation. Every other try to call the endpoint returns this. { "@odata.context": "$metadata", "value": [] }

After some investigation, I found an NPE in the code. You can see it on the attached screenshot.

Screenshot 2023-07-13 at 13 41 42

This is the object for which the error occurs:

@Entity @Table(name = "edges") public class WorkflowEdge {

@Id @ManyToOne @JoinColumn(name = "id") private Workflow workflow;

@Id @JoinColumn(name = "source") private Workflow sourceWorkflow;

@Id @JoinColumn(name = "target") private Workflow targetWorkflow;

Best Regards, Valeri

wog48 commented 11 months ago

Hello,

here we have two problems:

  1. Unfortunately, partly generated metadata are not destroyed in case an error occurs during the metadata generation. Therefor a second call returns the part generated till the error occurred. This could also be empty.
  2. Two of your navigations have no cardinality information sourceWorkflow and targetWorkflow. I'm not sure if JPA supports this. At least the JPA Processor requires this information. So you may need to add the corresponding annotation. Meaningful error message is missing.
Valeri-Velev commented 9 months ago

Hello,

Can I help somehow?

wog48 commented 8 months ago

With release 1.1.1, an error message has been added.