Hibernate version: 1.2 Beta 3
Name and version of the database you are using: SQL Server 2000/2005
I am unable to get Pessimistic Locking working under SQL Server 200x. My sample test case
does work with PostgresSQL 8.1. Here is my sample case:
Code:
string querySelectById = "SELECT report FROM Api.Report AS report WHERE report.ReportId = :ReportId";
public Report GetById(Guid id)
{
IQuery query = Session.CreateQuery(querySelectById).SetString("ReportId", id.ToString());
query.SetLockMode("report", LockMode.Upgrade);
return query.UniqueResult() as Api.Report;
}
When two threads run through this code, under PostgreSQL the second blocks on UniqueResult (until the first commits), under mssql they both run UniqueResult simultaneously.
What additional information can I provide?