0

我看过几页接近这个,但我正在寻找一个更简单的答案。

我有一个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在关联实体而不是属性上使用该子句。

这样做的正确方法是什么?

4

1 回答 1

2

您的 HQL 中没有语法错误吗?

where statement.FinancialStatementId := statementId

实际上应该是:

where statement.FinancialStatementId = :statementId
于 2012-06-23T18:17:41.893 回答