From: Max R. A. <ma...@eo...> - 2002-12-01 14:26:52
|
> P.S. I'm not keen on the way you add items to bidirectional association. The > correct idiom is: > > parent.getChildren().add(child); file://yes, even if the children collection is > readonly="true" > child.setParent(parent); > sess.save(child); > > omitting the first line could cause bugs in more complicated circumstances. Hmm - isn't this idiom inefficient ? Doesn't parent.getChildren().add() (or any method on the collection) result in loading all the children ? If the only intention is to add the child to the parent shouldn't the child.setParent(parent) be enough ? And then if I wish to have the parent in a "correct" state then I just do a s.load(parent, parent.getId()) ? /max |