无法使用实体管理器创建查询
Can not create the query using entity manager
当我执行此代码时 (JPA)
Query q=entityManager.createQuery(SELECT mc.account_no,mc.expiry_date,
SUM(CAST(CONCAT(mc.sign,mc.balance) AS NUMBER)),mc.moneybank_id FROM muthutcardbalance mc
WHERE mc.account_no='20' AND mc.scheme_code='MCB' AND mc.expiry_date >= '2015-07-28'
GROUP BY mc.expiry_date,mc.account_no ,mc.moneybank_id ORDER BY mc.expiry_date )
我收到以下错误。我对此感到震惊。
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT mc.account_no,mc.expiry_date,SUM(CAST(CONCAT(mc.sign,mc.balance) AS NUMBER)),mc.moneybank_id FROM muthutcardbalance mc WHERE mc.account_no='20' AND mc.scheme_code='MCB' AND mc.expiry_date >= '2015-07-28' GROUP BY mc.expiry_date,mc.account_no ,mc.moneybank_id ORDER BY mc.expiry_date ], line 1, column 49: unexpected token [(].
我正在使用 JPA 2 和 EclipseLink 2.0。
我的查询有什么问题?
但是当删除这个 SUM(CAST(CONCAT(mc.sign,mc.balance) AS NUMBER)) 它工作正常
createQuery 需要一个字符串作为参数,所以你应该双引号查询字符串
entityManager.createQuery("select * from dual")
当我执行此代码时 (JPA)
Query q=entityManager.createQuery(SELECT mc.account_no,mc.expiry_date,
SUM(CAST(CONCAT(mc.sign,mc.balance) AS NUMBER)),mc.moneybank_id FROM muthutcardbalance mc
WHERE mc.account_no='20' AND mc.scheme_code='MCB' AND mc.expiry_date >= '2015-07-28'
GROUP BY mc.expiry_date,mc.account_no ,mc.moneybank_id ORDER BY mc.expiry_date )
我收到以下错误。我对此感到震惊。
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT mc.account_no,mc.expiry_date,SUM(CAST(CONCAT(mc.sign,mc.balance) AS NUMBER)),mc.moneybank_id FROM muthutcardbalance mc WHERE mc.account_no='20' AND mc.scheme_code='MCB' AND mc.expiry_date >= '2015-07-28' GROUP BY mc.expiry_date,mc.account_no ,mc.moneybank_id ORDER BY mc.expiry_date ], line 1, column 49: unexpected token [(].
我正在使用 JPA 2 和 EclipseLink 2.0。
我的查询有什么问题?
但是当删除这个 SUM(CAST(CONCAT(mc.sign,mc.balance) AS NUMBER)) 它工作正常
createQuery 需要一个字符串作为参数,所以你应该双引号查询字符串
entityManager.createQuery("select * from dual")