我看过几页接近这个,但我正在寻找一个更简单的答案。
我有一个FinancialStatementLine
可以引用实体Payment
的对象。我想使用 HQL 来查找符合某些条件但没有关联对象的FinancialStatementLine
实体。我的 HQL 语句如下所示:Payment
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);
似乎这就是答案,但是我得到了一个NHibernate.Hql.Ast.ANTLR.QuerySyntaxException
(Antlr.Runtime.NoViableAltException) 并且我唯一能想象我做错的事情是尝试is null
在关联实体而不是属性上使用该子句。
这样做的正确方法是什么?