When i am executing this code (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 )
I get following error. Am struck with this.
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 [(].
I'm using JPA 2 with EclipseLink 2.0.
What is wrong with my query?
But when removing this SUM(CAST(CONCAT(mc.sign,mc.balance) AS NUMBER)) it works fine
createQuery expects a string as a parameter, so you should double quote the query string
entityManager.createQuery("select * from dual")