java.lang.illegalargumentexception:org.hibernate.hql.internal.ast.querysyntaxception:unexpected token:((带子查询)

v1l68za4  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(747)

我有一个mysql查询,它在 mysql workbench 但当我把同样的查询转换成 hibernate hql 它给出了以下例外

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 22 [SELECT COUNT(*) FROM (  SELECT pd.studentAdmissionId,SUM(fcm.feeAmount) - COALESCE(ft.amountPaid, 0)  AS due_amount  FROM com.rasvek.cg.entity.StudentPresentClassDetails pd INNER JOIN com.rasvek.cg.entity.FeeClassMapping fcm  ON pd.classId = fcm.classId  LEFT JOIN ( SELECT ft.studentDetails.studentAdmissionId ,SUM(ft.amountPaid) amount_paid  FROM   com.rasvek.cg.entity.FeeTransactions ft GROUP BY ft.studentDetails.studentAdmissionId ) ft ON ft.studentDetails.studentAdmissionId=pd.studentAdmissionId GROUP BY  pd.studentAdmissionId ) t  WHERE t.due_amount > 0]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
    at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:670)
    at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:103)
    at com.rasvek.cms.dao.MasterDaoImpl.getFeeDueCount(MasterDaoImpl.java:3951)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

请看查询

Query   query = currentSession.createQuery("SELECT COUNT(*) FROM ("
        + "  SELECT pd.studentAdmissionId"
        + ",SUM(fcm.feeAmount) - COALESCE(ft.amountPaid, 0)  AS due_amount "
        + " FROM StudentPresentClassDetails pd "
        + "INNER JOIN FeeClassMapping fcm  ON pd.classId = fcm.classId  "
        + "LEFT JOIN ("
        + " SELECT ft.studentDetails.studentAdmissionId ,SUM(ft.amountPaid) amount_paid "
        + " FROM   FeeTransactions ft "
        + "GROUP BY ft.studentDetails.studentAdmissionId "
        + ") ft ON ft.studentDetails.studentAdmissionId=pd.studentAdmissionId"
        + " GROUP BY  pd.studentAdmissionId ) t "
        + " WHERE t.due_amount > 0");

它有什么问题,在mysql工作台上运行得很好,但在hibernate中没有,我在代码中保留了额外的代码。
请帮帮我。谢谢您!。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题