Thanks Anne,  I'll give that a try.

On Apr 13, 10:50 am, Anne Epstein <[email protected]> wrote:
> Try making the relationship bidirectional, i.e. explicitly putting the
> parent Order object in OrderStatus, and marking the bag of
> OrderStatuses inside Order to be inverse in your mapping.  If you one
> have a single-direction relationship, you're going to get the behavior
> described.
>
> I believe the reasoning is something like this: since the relationship
> is one way, it's got to add the items from the side that is the
> dominant in the relationship, and to add an item, it's got to exist
> first.  So with the relationship being only on the parent end, it
> goes, adds the children, adds the parent, *then* adds all those
> children to the parent, now that it exists (relationship writes to db
> from parent->children even if it's weird).  In the case of the child
> being the dominant side of the relationship, it adds the parent, then
> adds the children, while setting the parent of all children to the
> parent row(relationship writes to db from child->parent).
>
>
>
> On Mon, Apr 13, 2009 at 10:01 AM, Phil <[email protected]> wrote:
>
> > Hi everyone,
>
> > I have an Order object that is mapped to an Order table in the
> > database.  I also have a child OrderStatus object that's mapped to an
> > OrderStatus table in the database.
>
> > For this to work, I have to allow the OrderID column in the
> > OrderStatus to be Nullable.  It looks like NHibernate inserts the rows
> > into the child table first and has to insert a null for this OrderID,
> > then it inserts the row into the Order table, and finally updates the
> > OrderStatus with the correct OrderID value.
>
> > Is this how NHibernate works?  is there any way around this?  I can
> > always make the OrderID column nullable, but it's part of my primary
> > key.  Do I just need to use an identity for the Primary Key in my
> > OrderStatus table, and make the OrderID Nullable?
>
> > thanks in advance for any help,
>
> > Phil- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to