org.hibernate.QueryException: unexpected token: WI

2019-08-16 13:22发布

问题:

Hi am trying to join the tables with specific condition and when i executing the below query and am getting the below error

 org.hibernate.QueryException: unexpected token: WITH [

my HQL QUERY is below...

> 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();

In the financialDetail.hbm file i have a mapping between these two table like

<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>

Pls guide me what is wrong here...

回答1:

You should try to put 'fhdrinfo.chk='224' into the where-condition.

 where financialDetail.fc=:fc and fhdrinfo.chk='224'