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
123 stars 76 forks source link

POSTing new entity with @ManyToOne relation failing #146

Closed ajheflin closed 2 years ago

ajheflin commented 2 years ago

Attached is a screenshot of the request being made to the endpoint: image

And the error being returned is Cannot insert the value NULL into column 'issue_id', table 'db.logs'; column does not allow nulls. INSERT fails

The database name has been obscured for privacy reasons but the database is MS SQL.

The entity class for Log is as follows: image

It's worth noting that created, createdBy, modified, and modifiedBy are all values that are calculated as the object is being persisted, and do not need to be posted with the request body.

wog48 commented 2 years ago

Two questions:

ajheflin commented 2 years ago

I cloned the latest. My pom.xml says 1.0.6.

I ended up resolving it by creating a custom implementation of the CUDRequestHandler, but originally I was using the default one, yes. I'm mostly just curious if the error originally was something on my end or an issue with the framework. I had also tried creating an IDClass that implemented Serializable but no dice there, either.

wog48 commented 2 years ago

The idea of JPAExampleCUDRequestHandler is to support you in rapid prototyping, it may not be able to handle all situations. As the ìmplementation of JPACUDRequestHandler is the place to implement business logic the JPA Processor can only provide some supporting functions.