Upon running a fairly simple select HQL query I get this error:
"Cannot insert duplicate key row in object 'dbo.PayrollBatchDrivers' with unique index 'IX_PayrollBatchDrivers_DriverID_PayrollBatchID'.
The statement has been terminated."
Here's the code snippet:
Code:
IQuery query = NHibernateSessionProvider.Session.CreateQuery(hqlQuery);
IList result = query.List();
Here's the HQL:
Code:
select
e.Id, e.TypeString, e.Amount, e.Comment
from PayrollBatchDriverExpense e
where e.Driver.Driver.Id = 20886 and e.IsActive = 1
and e.Driver.PayrollBatch.Id = 81
Now, before this HQL query I have fetched an object and made some modifications to it. Its seems that the List() method is wanting to flush the session and save those changes. Never mind that I don't see why a flush would even cause this error, I don't want a flush to happen.
Can anyone explain why calling IQuery.List() with a select would try to do any inserts? Thanks.