I'm using the NHibernate(version: 3.3.1.4000) and I'm trying execute an HQL query, with a subquery as a SELECT value. It works fine, the problem is when there is no data in the subquery, then I'm having the following error:
- "No row with the given identifier exists[namespace.Table2#-2147483648]"
The code example:
IQuery query = session.CreateQuery(@"SELECT tb1,
(SELECT tb2
FROM Table2 tb2
WHERE tb2.IdVal = tb1.IdVal
AND tb2.Id2 = :id2)
FROM Table1 tb1
WHERE tb1.Cod = :cod1");
IList<object[]> dataResult = query.SetParameter("id2", "value")
.SetParameter("cod1", 1).List<object[]>(); // The error is trown in this Line
I want to know how can I avoid this error, I just want the subquery return a "null" value when there is no data.
I'll be grateful for any help. Thanks in advance.