I've created a simple DB in MYSQL:
I've also created the JPA entities based on this and exposed it using Olingo v2. When I try to create a client entity through postman it works fine
{
"Name": "John Doe"
}
however when I try to create an address
{
"Street": "Street for John Doe",
"Zipcode": "444465",
"Client": 1
}
it fails with
MySQLIntegrityConstraintViolationException: Column 'clientId' cannot be null
This error is expected since I made it not nullable
However I was assuming that "Client": 1 would be properly processed and transformed into the query:
ClientId
Column is available in the Address
entity as a join column:
//bi-directional many-to-one association to Client
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name="clientId")
private Client client;
I've tried changing the JSON format to create a sub object Client within Address like this:
{
"Street": "Street for John Doe",
"Zipcode": "444465",
"Client": { "Id": 3 }
}
but this ends up with a 400 - "The Request Body is malformed"
Am I mising some annotation on the Client property or something else?
Note: If I remove the join column and create a column clientId the insert/update works fine... however in this situation I end up loosing the navigation capabilitites of the Odata Model
Thanks for the feedback,
Regards
Pedro