Hi, I am using Cayenne in a web app (through AgRest, but this is purely cayenne related, well I think so) that contains one service through a POST method. Basically, I submit a JSON body with multiple object in it, pass it through the service method defined below, process each object and for each ones doing some insert into an Oracle DB. @POST @Consumes(MediaType.APPLICATION_JSON) @Path("getid") @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") public List<IdResponse> getID(final List<IdInput> inputs) { There I loop over this list, process the object IdInput and make the necessary insertions }
My issue there is that when I commit the changes, the order of the inserts seems to fail randomly, from one request to another. I have relationships set in those modifications, and through the logs I can see the PK being fetched from the sequences, but then sometimes (most of the times) the referencing entity is inserted before the referenced entity. And of course the commit fail for violation of parent key. I've tried to secure as much as possible the context, through different ways: * stateless thread context through the provided cayenne filter (stateless because the session one would be committed via another commit made in another filter, weird, but I send only one request, this filter commit should happen prior to the 'service' commit) * per method context * custom stateless context through a filter that I made myself. I thought I got it with he per method context, but it failed after a while. And I tried committing after each processing in the loop, or after the loop, but same results. I'm probably missing something, but I'm not getting why it happen sometimes, not always(or never!). A threading issue maybe? But I'm processing only one request, so I'm a bit lost. Any thoughts? (before I commit after each insertion of entities haha) How the order of inserts are defined? Maybe I miss-configured some relationships in the modeler, but they come from a reverse engineering and look ok... Many thanks in advance Anthonin ________________________________ Ce message et toutes les pi?ces jointes (ci-apr?s le "message") sont ?tablis ? l'intention exclusive de ses destinataires et sont confidentiels. Si vous recevez ce message par erreur ou s'il ne vous est pas destin?, merci de le d?truire ainsi que toute copie de votre syst?me et d'en avertir imm?diatement l'exp?diteur. Toute lecture non autoris?e, toute utilisation de ce message qui n'est pas conforme ? sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite. L'Internet ne permettant pas d'assurer l'int?grit? de ce message ?lectronique susceptible d'alt?ration, l'exp?diteur (et ses filiales) d?cline(nt) toute responsabilit? au titre de ce message dans l'hypoth?se o? il aurait ?t? modifi? ou falsifi?. This message and any attachments (the "message") is intended solely for the intended recipient(s) and is confidential. If you receive this message in error, or are not the intended recipient(s), please delete it and any copies from your systems and immediately notify the sender. Any unauthorized view, use that does not comply with its purpose, dissemination or disclosure, either whole or partial, is prohibited. Since the internet cannot guarantee the integrity of this message which may not be reliable, the sender (and its subsidiaries) shall not be liable for the message if modified or falsified.