HQL查询不适用于减去列

时间:2017-07-19 13:22:07

标签: hibernate hql

我所有的表都有一个信用列,在借记栏上我想要汇总所有借记栏并从信用栏的加法中减去它。我无法使用hql。

下面是我的hql查询。

select debitL FROM ( ("
        + " select eie.trustId as trust_id, sum ( eie.amount ) as sumdr from EntryItemEntity as eie where"
        + " eie.debitOrCredit = 'dr' group by eie.trustId  ) debitL inner join"
        + " ( select eie.trustId as trust_id, sum ( eie.amount ) as sumdr from EntryItemEntity as eie where"
        + " eie.debitOrCredit = 'cr' group by eie.trustId ) as creditL where debitL.trust_id = creditL.trust_id )

但我收到了以下错误

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 21 [ select debitL FROM ( ( select eie.trustId as trust_id, sum ( eie.amount ) as sumdr from jm.gov.agd.trust.model.EntryItemEntity as eie where eie.debitOrCredit = 'dr' group by eie.trustId  ) debitL inner join ( select eie.trustId as trust_id, sum ( eie.amount ) as sumdr from jm.gov.agd.trust.model.EntryItemEntity as eie where eie.debitOrCredit = 'cr' group by eie.trustId ) as creditL where debitL.trust_id = creditL.trust_id )]

请帮助我实现这一目标。

提前致谢。

0 个答案:

没有答案