@nadav. I saw posts suggesting that inverse="true" should be used, but
those are mainly for bi-directional associations. Nevertheless, I have
tried it, and it didn't help. Even more, it didn't work at all!
(foreign key was not populated)

@Fabio: the classes are here: http://dl.dropbox.com/u/163584/NHModels.zip.
If needed, I can prepare a complete repro solution.

On Mar 28, 7:43 pm, Fabio Maulo <[email protected]> wrote:
> Can you send the classes ?
> I would see something.
>
> 2010/3/28 Miha V <[email protected]>
>
>
>
> > Hi!
>
> > I'm trying to figure out, why NHibernate inserts the entity, and then
> > (only if within transaction) updates the entity with foreign key.
>
> > The setup:
> > EntityA
> >  PropA
> >  IList<EntityB> PropB
>
> > EntityB
> >  PropC
> >  PropD
>
> > I'm using FluentNH to configure this, and the generated HBM looks
> > correct, and EntityB gets a foreign key EntityA_id. What's weird
> > though is this:
>
> > 1) If I'm not in the transaction, NH only inserts Entity in DB,
> > without populating foreign key EntityA_id. This results in orphan
> > elements in the databse and, well, it's incorrect since EntityA has no
> > children. The cascade is set to all.
>
> > 2) If I'm in the transaction, NH **updates** the EntityB table
> > **after** inserts with the foreign key. This works and is correct, but
> > the update at the end should IMHO be moved to "insert phase".
>
> > Question1: Why does this behaviour change whether I'm in a transaction
> > or not?
>
> > Question2: is there a way to "force" NH to populate the foreign key in
> > the insert?
>
> > For reference, here are the actual HBM files: (Document contains
> > DocumentPart(s))
> >http://dl.dropbox.com/u/163584/HBM.zip
>
> > Thanks,
> >  Miha.
>
> > --
> > 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.
>
> --
> 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.

Reply via email to