Datetime compare problem when using Stored Procedure in NHibernate

One of my SP does the update based on a full column value match, not only on primary key column. When I got a wired  Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing’ problem on some updates, I think this must caused by that column match. Commented out one datetime column matching in where clause, problem disappear.

The ideal way to fix this problem should be, switch the hard match

where datatime_a = datetime_b


datediff(s, datatime_a, datetime_b) = 0

Similar to float type equality check.

But why this problem only happens to NHibernate?


3 thoughts on “Datetime compare problem when using Stored Procedure in NHibernate

  1. Pingback: Compare Linq to SQL with NHibernate « maonet technotes

  2. From Applying Domain-Driven Design and Patterns: With Examples in C# and .NET, 1/e By Jimmy Nilsson,

    — The precision is down to 100 nanoseconds for .NET, but “only” down to 3/1000 of a secound in SQL Server.

    Is that the reason? Why Linq To SQL doesn’t have this problem? Anywhere Microsoft did a magic convert?

  3. Sometimes this problem also appears when using LinQtoSQL, the problem is the parameters mismatch in SP definition.
    Unit test is so good.

    public void CanUpdateTrainee()
    Trainee oldTrainee = dbx.GetTraineeById(2);
    oldTrainee.Given_Names = “AAAA”;

    Trainee newTrainee = dbx.GetTraineeById(2);
    Assert.AreEqual(“AAAA”, newTrainee.Given_Names);

    newTrainee.Given_Names = “FFFF”;

    Trainee restoredTrainee = dbx.GetTraineeById(2);
    Assert.AreEqual(“FFFF”, restoredTrainee.Given_Names);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s