PeteWeissbrod wrote:
Hi this is a general question about NHibernate 1.2...
I want to save an object, but I do not want the INSERT command to occur before the session.Flush()...
I tried setting the Session.FlushMode to FlushMode.Never, but it still onvokes an INSERT command immediately.
how can I control this?
These are both helpful clues.
#1. if you use <generator class="identity" />, an INSERT command will happen immediately after the Save(..) call, this is by design, because the ID is assigned to the SCOPE_IDENTITY.
#2. you should not care when the insert occurs... If your session is properly wrapped inside of a transaction,
the insert is not committed until the transaction is committed.
This alone is a good reason to use transactions with ANY session interaction, it gives you a higher degree of control over your database interactivity.
thanks guys!