Probably because if you use Identity, the entity's state gets sent to
the db as soon as you call Save(), rather than when the session is
flushed. See 
http://ayende.com/Blog/archive/2009/03/20/nhibernate-avoid-identity-generator-when-possible.aspx
and the articles it links to.

On Dec 31 2010, 10:05 pm, Tim Scott <[email protected]>
wrote:
> Never mind.  I had an error in the way I manage life-cycle of the
> session.  Not sure why it worked before changing to GUIDs.
>
> On Dec 31, 2:39 pm, Tim Scott <[email protected]> wrote:
>
>
>
>
>
>
>
> > I changed from int (identity) to Guid ids.  Now when I save a new
> > entity, nothing happens.  The code has not otherwise changed.
>
> > After calling Save my entity gets a non-empty id.  Before changing to
> > Guids, calling Session.Transaction.Commit() would cause the insert to
> > happen.  (Flush mode is Commit.)  Now nothing.  I notice that after
> > the Save, Session.Statistics.EntityCount = 0.  The newly saved entity
> > is not even in my session.  What?  I tried using SaveOrUpdate instead
> > of Save.  No difference.
>
> > I've used Guid ids with NH before, but never with Fluent NH.  Am I
> > missing something?  From the docs, it appears the defaults are what I
> > want, but I tried to be explicit as well:
>
> > instance.GeneratedBy.GuidComb();
> > instance.UnsavedValue(Guid.Empty.ToString());
>
> > No difference.  Any ideas are appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en.

Reply via email to