--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
in fact most of them scare me a bit because I'm using assigned GUID's
and I see that you discourage this practice... I guess that all
already persisted entities are previously loaded but I clearly
identify from your replies that the tree entities construction in my
application has some flaws.
BTW if I use generated GUID like with comb strategy after every insert
NH will need to query again to retrieve this generated field and at
the end I will need another select for each insert. Right?
Version(entity => entity.Version)
I believe you could alternatively go with timestamp here, but haven't
done that personally.
Hope that helps!
I suspect that you've not told NHibernate how to know that it's a new child (by way of the unsaved-value attribute. However, is it really true that the index is part of the child's PK as opposed to a UQ? My reading of the pseudo-code is that you've got a parent with an ordered list of children; is the order guaranteed immutable (including no deletes, ever!) and truly an identifier? If you ever delete or re-order children then I'd suggest that the child is promoted to a 'first class' entity with it's own ID. FWIW, when I have this situation my pattern tends to be:
TChild:
Parent {get;protected set;}
Index { get { return Parent.Children.IndexOf(this); } }
Child(Parent parent) {
if(parent == null) throw;
}
/Pete
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/ygu-KT2PgY4J.
Yes, I'm quite familiar with dependent entities... unfortunately, the simplified code in your original question doesn't seem to match your current question and so of course the answer is different too! For the question you're now asking, I'd suggest looking at a component-id (http://nhforge.org/doc/nh/en/index.html#components-compositeid) plus a version to allow transience detection.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/gA9HbYDZSDwJ.