【发布时间】:2016-08-09 14:58:16
【问题描述】:
您好我正在尝试加入具有特定条件的表,当我执行以下查询并收到以下错误时
org.hibernate.QueryException: unexpected token: WITH [
我的 HQL 查询低于...
> List results1=session.createQuery("select financialDetail from
> FinancialDetail financialDetail " +
> "left join financialDetail.financialClaimHeaderInfo fhdrinfo WITH (fhdrinfo.chk='224') "+
> " where financialDetail.fc=:fc")
> .setParameter("fc",fc)
> .list();
在 FinancialDetail.hbm 文件中,我有这两个表之间的映射,例如
<set name="financialClaimHeaderInfo" table="F_CLM_HDR_TB" lazy="true" inverse="true" cascade="all" > <key column="F_FCN_NUM" /> <one-to-many class="com.FinancialClaimHeaderInfo"/> </set>
请指导我这里出了什么问题...
【问题讨论】:
-
@RealSkeptic:我听说在休眠中 ON 不可用。这就是我使用 WITH 的原因
-
关键字是否正确?您应该尝试将 'fhdrinfo.chk='224'' 放入 where 条件: where financialDetail.fc=:fc and fhdrinfo.chk='224'
-
我的要求是我需要从 FinancialDetail 中获取所有行 + 从 fhdrinfo 中获取行,其中 fhdrinfo.chk='224'