Hi.

We're migrating a legacy project from a proprietary in-house ORM to
NHibernate 3.0.0 on .net 4, and it is working fine.

However, I have a question regarding when to call Session.Save(), when
we create new instances.

pseudo code: (1)
var p = new Parent();
var c = new Child();
_session.Save(p);
_session.Save(c);
c.Parent = p;
p.Children.Add(c);
_session.Flush();

If we do the above, nhibernate translates it to two statements, an
INSERT and UPDATE.
But, the Child has not-null constraint on its foreign key so INSERT
fails.

It works If we do: (2)
var p = new Parent();
var c = new Child();
p.Children.Add(c);
c.Parent = p;
_session.Save(p);
_session.Save(c);
_session.Flush();

The above samples are simplified, but illustrates our issue quite
well.

We'd like to do the (1), as that would require the least changes in
our code. Is it possible to tell NHibernate to only make one INSERT
instead of INSERT & UPDATE in that case?

Best regards,
./Daniel

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