I think you need to understand how cascade="all" interacts with unsaved-value, etc. If you have cascade="all", update(parent) will pass the children to saveOrUpdate(). If the children have unsaved-value="none", they will all get updated; if they have unsaved-value="any", they will all get inserted. So if you don't want this behaviour, you can easily change it by disabling the cascade and explicitly save() or update()ing each child. I personally believe this is a good way to go, because it makes your meaning quite explicit in the code (and is efficient).
Or else you could use synthetic ids, which is a much better approach for all sorts of reasons, but that also gives you the benefits of unsaved-value="null". (Which will dissolve all your issues here instantly.) This is all explained quite clearly in the documentation. Have you sat down and read it from top to bottom yet? Aside from the (fixed) bug in 1.2.2, the semantics here are *quite* clear and well defined if you read the documentation carefully. peace Gavin "Matt Raible" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent by: cc: [EMAIL PROTECTED] Subject: [Hibernate] RE: composite-id still doesn't work for me... eforge.net 24/01/03 12:16 AM So is it possible to get a parent w/ children and only make a call to update(parent)? From your e-mail below, I gathered that I could change my storeObject() method to use update() rather than saveOrUpdate() and everything would work peachy-keen. Nope, I still get the same error - so obviously this is not the case. But from the FAQ (http://hibernate.bluemars.net/14.html#10), it seems to imply that I need to loop through all the children, doing update(child) and then do an update(parent). If I do this, I'd think that I would need to remove the children from the parent before calling update(parent). I don't mind doing it this way - I just want to make sure I'm following "best practices" for parent-child relationships with composite-ids. Thanks, Matt In reply to: http://sourceforge.net/mailarchive/forum.php?thread_id=1557661&forum_id= 7517 Of course! Its a FAQ item that assigned ids including composite ids can't distinguish between a saved or unsaved object (you have a choice between "always update" or "always insert"). So if you want to add a new child (with unsaved-value="none"), simply save () it manually first: child.setParent(parent); parent.addChild(child); session.save(child); session.update(parent); None of these things are issues if you use synthetic ids, as is best practice for all sorts of other reasons (see Scott Ambler's paper). ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel ********************************************************************** Any personal or sensitive information contained in this email and attachments must be handled in accordance with the Victorian Information Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988 (Commonwealth), as applicable. This email, including all attachments, is confidential. If you are not the intended recipient, you must not disclose, distribute, copy or use the information contained in this email or attachments. Any confidentiality or privilege is not waived or lost because this email has been sent to you in error. If you have received it in error, please let us know by reply email, delete it from your system and destroy any copies. ********************************************************************** ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel