I’ve seen a couple pages that come close to this, but I’m looking for a simpler answer.
I have an object FinancialStatementLine that can reference a Payment entity. I want to use HQL to find the FinancialStatementLine entities that match certain criteria but do not have an associated Payment object. My HQL statement looks like this:
var query = _Session.CreateQuery(
@"select lines from FinancialStatementLine lines
inner join fetch lines.Statement statement
where statement.FinancialStatementId := statementId
and lines.Payment is null
and length(lines.CheckNumber) > 0")
.SetParameter("statementId", financialStatementId);
It seems that would be the answer, but I’m getting a NHibernate.Hql.Ast.ANTLR.QuerySyntaxException (Antlr.Runtime.NoViableAltException) and the only thing I can imagine that I’m doing wrong is trying to use the is null clause on an associated entity instead of a property.
What is the proper way to do this?
Don’t you have a syntax error in your HQL?
should actually be: