based on your mapping, 'inverse=true' would prevent the order from having
responsibility to save the transaction.  in the AddTransaction method, you
would need to do "tx.Order = this;

On Thu, Apr 15, 2010 at 8:12 AM, ben <[email protected]> wrote:

> I have recently started learning NHibernate and am struggling to find
> documentation on how to handle updates in a set.
>
> For example, I have an order object with a one to many relationship to
> transaction. My transaction table has a foreign key OrderId. The xml
> for my mapping is:
>
>     <set name="Transactions" table="Transactions" inverse="true"
> lazy="false">
>      <key column="OrderId"/>
>      <one-to-many class="Transaction"/>
>    </set>
>
> What I would like to do is to add transactions like so:
>
> Order order = repo.GetById(id);
> Transaction tx = new Transaction();
> order.AddTransaction(tx);
> repo.Update(order);
>
> When I issue ISession.Update I would expect that any new transactions
> added to the Order object are saved to the database (via an insert
> command).
>
> In order to achieve this I set the cascade attribute for the above
> set.
>
> However, in addition to adding any new transactions an update command
> is issued for every existing transaction (I have checked in NHProf and
> an update command is generated for each transaction setting all
> columns to the original values).
>
> Have anyone got an example (or perhaps a link) to an example that
> demonstrates how this should work?
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
thanks

cliff

-- 
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