In Hibernate and JPA we can use a flag called "deleteOrphans", so when those frameworks load collections, we use this flag to delete or not removed elements from collections.
I tried to code something like that, but I can't identity when a list element was retrieved from database or was just created. Sent with MailTrack<https://mailtrack.io/install?source=signature&lang=en&[email protected]&idSignature=22> Estevão de Freitas Góes ------------------------------------ Analista de Sistemas Bel. Ciências da Computação (UFMA 2010) 2014-04-16 5:39 GMT-03:00 Lukas Eder <[email protected]>: > Hello Estevão, > > Thanks for your suggestion. I'm afraid that you will currently need to > maintain two separate lists, e.g. > > List<People> people = ... > List<People> removed = new ArrayList<>(); > removed.add(people.remove(people.size() - 1)); > > ctx.batchStore(people).execute(); > ctx.batchDelete(removed).execute(); > > > I wonder if a batchMerge() could be implemented. The question, however, > would be how to identify those records that should be removed...? > > Cheers > Lukas > > > 2014-04-15 19:26 GMT+02:00 Estevão Góes <[email protected]>: > > Hi all, >> I recently discovered the DSLContext.batchStore method that can save or >> update records from a list direct to database. This is fabulous. Great code. >> But I'm just wondering how I can handle removed records from list. Should >> I maintain a complementary list of removed records, or did I code something >> wrong? >> >> This is my code: >> >> List<Person> people = DSLContext.fetch(Tables.Person); >> people.remove(people.size() - 1); //it removes last person >> DSLContext.batchStore(people).execute(); //it doesn't work, the record is >> not deleted. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "jOOQ User Group" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
