Hello everyone,
I’m having some issues about updating an object from an external webapp.
I need to update an object that contains nested object (some are even a list of nested objects) and the native axelor end-point updates only the parent object.
For example, if i have a Person that contains Address and a list of Planning, using the documentation update endpoint, it will only update the Person informations, not the Address nor Planning.
Also, i tried to create a custom endpoint using the JPA library available in Axelor. I also have issues using these methods as i encounter a Constraint Unique Key Violation for the nested objects.
For exemple, for the same Person as before, on update, the console says that the id already exists. BUT! The thing is, it looks like it creates a new line in the database (eventhough it doesn’t) as the id of the address is id = 2 and the error says that the id = 3 already exists. If i run the update once again, the console indicates that the id = 4 already exists (which doesn’t by the way).
I checked the generated domain classes, but the annotations for the @OneToMany or the @ManyToMany contains the rights properties :
fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE }
for the JPA update cascade to occur (at lest in pure Java style).
Do you have anything that could help me? We use the 5.1.2 version of Axelor.
Thanks a lot!
UPDATE: When i use the same method using a completely new JSON body (Person, address, list of planning), i actually get the same Constraint Violation error…
Precision, i’m using :
@PUT
@Path(« /v1/update »)
As decorators for my Controller method, endpoint which i call via Postman using a JSON as a body.
I tried as well using the @POST decorator instead of @PUT (out of despair), got the same error message.