Only things that come to mind quickly are: Use a custom Criteria to build a NOT IN clause that with an expression to combine your keys. E.g. build the following sort of Custom criteria:
CONCAT(CAST(Book.ID1 AS CHAR),'-',CAST(Book.ID2 AS CHAR)) NOT IN ( '1-1', '2-1',...) Alternatively, you could just add a unique non-key record id to book table. It doesn't have to be the key, just an auto increment field. Then you could just use a normal NOT IN criteria. > -----Original Message----- > From: Thomas Fischer [mailto:[EMAIL PROTECTED] > Sent: Friday, March 28, 2008 11:23 AM > To: [email protected] > Subject: saving the state of a object collection > > > Has anybody found a simple way to save the state of object collections > ? > To illustrate what I mean, here's an example (I'm using > complexObjectModel > = true and objectIsCaching = true): > > I have two tables, Book and Author. A foreign key exists from book to > Author, so an author can have several books associated. > Now I load one author including the associated books. I modify the > associated set (i.e modify, add and delete books) and want to save it > as it > is (i.e. after saving, the list of associated books in the database > should > be exactly equal to the list of books in the author object). > > The algorithm I can come up with is the following: > 1) select the ids of all books in the author object which are not new > in a > collection > 2) delete all books for the author which have an id not in the above > collection of ids > 3) save the author (this will save the underlying books as well) > > 2) is painful if the book table has a composite primary key (as I > cannot > see how Criteria.NOT_IN should work in this case (or does It ? please > tell > me!)) > Does anybody see an easier way to do this ? Hitting the database during > modifying the book list is not an option in my case because the > possibility > to NOT save the changes should exist after making the changes in the > GUI > > Thomas > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] DukeCE Privacy Statement: Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed. If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately. Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
