You could create a dialect subclass and just override
"IdentitySelectString" to use @@identity instead of scope_identity(). That
could of course have undesired side effects if you have other triggers.

/G

2016-03-01 19:49 GMT+01:00 Steve Lyle <[email protected]>:

> The following
>                     txn = ses.BeginTransaction(); //)
>                     ses.Save(employee);
>                     txn.Commit();
>
> throws
>                     IsolationLevel =
> '((NHibernate.Transaction.AdoTransaction)txn).IsolationLevel' threw an
> exception of type 'System.NullReferenceException'
> on the Commit()
>
> But when I profile the SQL server the profile captures a successful SQL
> insert.
> The problem is immediately following the Insert is "select
> scope_identity()" issues by nHibernate.
>     Scope_Identity() returns null to the application because the table I'm
> inserting into has a "instead of insert" trigger.
> I can add the scope_identity() to the trigger, and it is successful is
> capturing and reporting the inserted identity, but the application never
> gets the value.
> So the Commit() rollsbacks my successful insert because of the false
> positive on nHibernate's scope_identity().
>
> What is the workaround to this?
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to