No one of all. On Tue, Apr 19, 2011 at 11:58 AM, Arnon Axelrod <[email protected]> wrote:
> Hi, > > Suppose I have an Order class with an 'IList<Item> Items' property > (Item is another class). Item doesn't point back to its containing > Order. The mapping is as follows: > > <bag name="Items" cascade="all-delete-orphan"> > <key column="OrderId"/> > <one-to-many class="Item"/> > </bag> > > When I create a new Order and fill its Items property with new > instances of Item and then save the Order, I see the following queries > are executed: > 1. An INSERT for the Order > 2. An INSERT for each Item, without the OrderId column > 3. An Update for each Item setting the OrderId to the Id of the Order > > What I don't understand is why NHibernate can't add the OrderId in the > INSERT statement (#2) and needs another round-trip for that? > > I see that if I add a reference back from Item to its Order then I can > use inverse="true" and as a result the UPDATE statement will be > avoided. But I prefer not to add a property I don't use otherwise, and > which I need to manage its consistency. > > Is there a way to do it without adding a reference from Item to its > Order, or is there a good reason why NH can't optimize it? (or maybe > it's just a good idea that wasn't implemented yet :-)) > > -- > 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. > > -- Fabio Maulo -- 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.
