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]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
