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
to
datediff(s, datatime_a, datetime_b) = 0
Similar to float type equality check.
But why this problem only happens to NHibernate?
Advertisements
Pingback: Compare Linq to SQL with NHibernate « maonet technotes
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?
Sometimes this problem also appears when using LinQtoSQL, the problem is the parameters mismatch in SP definition.
Unit test is so good.
[Test]
public void CanUpdateTrainee()
{
Trainee oldTrainee = dbx.GetTraineeById(2);
oldTrainee.Given_Names = “AAAA”;
dbx.SubmitChanges();
Trainee newTrainee = dbx.GetTraineeById(2);
Assert.AreEqual(“AAAA”, newTrainee.Given_Names);
newTrainee.Given_Names = “FFFF”;
dbx.SubmitChanges();
Trainee restoredTrainee = dbx.GetTraineeById(2);
Assert.AreEqual(“FFFF”, restoredTrainee.Given_Names);
}