1

请帮我解决我的问题 - 如果我在 sqlplus 中运行相同的查询,它工作正常。

net.sf.hibernate.QueryException: , expected in SELECT [SELECT SUM(CASE WHEN s.SettlementCurrencyName = r.ContractCurrency THEN p.ContractNet WHEN s.SettlementCurrencyName = r.LocalCurrency THEN p.ContractNet/ta.LiquidationRate WHEN s.SettlementCurrencyName IS NULL THEN p.ContractNet/ta.LiquidationRate ELSE p.ContractNet/ta.LiquidationRate END)"PAID AMOUNT", COUNT(t.TX_IDENTIFIER) "PAID TXS" FROM com.uniteller.txcore.Payment p, com.uniteller.txcore.Transaction t, com.uniteller.txcore.TxAccounting ta, com.uniteller.txcore.Remittance r, com.uniteller.txcore.SellingAgentSettlement s WHERE t.isLRCTx = 1 AND t.SellingCompany = :lrcCode AND s.SettlementCurrencyName(+) = r.ContractCurrency AND s.Id.DestCurrencyName(+) = r.ContractCurrency AND s.Id.Code(+) = r.SellingAgent AND r.ContractCurrency = :contractCurrency AND p.PaidAccountDt > :lastPaidAcDt AND p.TxIdentifier = t.TxIdentifier AND p.TxIdentifier = r.TxIdentifier AND p.TxIdentifier = ta.TxIdentifier]
at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:169)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:295)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1572)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at com.uniteller.tools.databroker.Main.main(Main.java:85)
4

2 回答 2

1

我认为问题可能在于您尝试将查询作为 HQL 查询执行:

Query query = session.createQuery(...);

但正如我所见,您的查询不是 HQL,这就是为什么您应该将其作为本机 sql 查询执行:

SQLQuery query = session.createSQLQuery(...);
于 2012-08-04T07:50:18.370 回答
0

)"PAID AMOUNT" 在 ) 和 " 之间需要一个空格

于 2012-08-04T08:14:03.003 回答