I have a Parent object with a list of Child objects (one-to-many,
cascade-all)
and each Child object has an Optional component (many-to-one, cascade-
all)
ie Parent  1----*  Child  1----0/1  Optional

When doing a flush/commit i get this error: "object references an
unsaved transient instance" but it's NOT due to lack of cascade
settings (which seems to be the most common reason for encountering
this error).

Instead, this error is occurring because the Child collection is being
hydrated and a new Optional object is being created during a flush
operation.

As far as i can tell, the sequence of events is:
 - commit/flush
 - calls Session.FlushEverything()
 - calls PreFlushEntities() then FlushEntities() which crashes

Stepping through the debugger, i noticed that PreFlushEntities() is
accessing the Child list getter on Parent. No surprise here, but my
getter is coded to sort the list on first access, which naturally
hydrates the collection. Certain Child objects automatically add an
Optional object if one is not already present, and it is for these
Optional objects created during the flush operation that the error is
being raised for.

I realise that my Child list getter may be a little unorthodox, but is
it such a big no-no to be causing hydration and new object creation in
a collection getter? Or have stumbled across a bug?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to