Hate to reply to my own messages, but seems like some already asked the same question (without an answer) at http://archives.apache.org/eyebrowse/ReadMsg?listName=turbine-torque- [EMAIL PROTECTED]&msgId=413140
Anyone got a clue? G. On Wednesday, September 18, 2002, at 11:12 am, Gareth Boden wrote: > I think there's a problem with the copy/copyInto() implementation > (using b3, can't yet get maven to run to build b4). > > When you copy an object which has children, the children are duplicated > in an odd way. An example (for a house with rooms): > > Model: > House [houseId = 1] > Room [houseId = 1, roomId = 1] > > Code: > House h = HousePeer.getHouse(1); > House h2 = h.copy(); > h2.save(); > > Problem: > copy() calls copyInto(), which first of all calls setNew(false) and > copies the fields on the House (no problem here). > At the end, it unsets the houseId on House and calls setNew(true) > again. (no problem here either). > In between, it does the following for each Room related to House 1: > a) Call Room.copy(); > b) Call House.addRoom() on the new house. > c) Call setNew(true) on the old Room (which seems odd). > It's (b) that's the problem. House.addRoom() first calls > getRooms().add, and getRooms(), since the House has isNew()=false, > fetches the rooms which match the houseId (which has not yet been > unset). So currently, collRooms contains the old room. And that's > before the second part of addRoom(), which actually calls add() on the > collection. So we end up with the new House's collRooms containing two > entries, one old and one new. At this point it all gets a little > confused. > > Am I wrong, is it wrong, and does anybody know what's supposed to > happen here? > > Gareth > --- Development Team Leader, eGS, 5-7 Singer Street, London EC2A 4BQ. +44 (0)20 7336 1440 CONFIDENTIALITY: This is email is confidential and intended solely for the use of the individual to whom it is addressed.� Any views or opinions presented are solely those of the author and do not necessarily represent those of eGovernment Solutions (UK) Ltd.� If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, or copying of this email is strictly prohibited.� If you have received this email in error please contact the sender. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
