请帮助我解决我的问题 - 如果我在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)
答案 0 :(得分:1)
我认为问题在于您尝试将查询作为HQL查询执行:
Query query = session.createQuery(...);
但是当我看到您的查询不是HQL时,这就是为什么您应该将其作为本机sql查询执行:
SQLQuery query = session.createSQLQuery(...);
答案 1 :(得分:0)
)“PAID AMOUNT”需要一个空格和“