I’m still not 100% sure what the ideal solution is when manipulating new entities with a middleware service. E.g. we have
user 1..n document composition, where the
document entity can be manipulated via a middleware service.
When I insert a new company entity (CompanyEdit) and then add a new document entity (now I am in DocumentEdit) and here I have a function that will call the middleware service to manipulate the document entity I will have to persist the document entity first.
The service now sets some fields in the document entity, persists the result and returns. Now I have to reload the entity in the edit screen.
It is even trickier, if I need the newly created company entity in the service call, because then I’d also have to persist the company entity, before I invoke the service call.
So, what’s the best way of dealing with new entities (also nested new entities as outlined in my short example) in a middleware service?