我正在使用Eclipselink 2.2.1.v20110722-r9776
我有以下查询:
TypedQuery<FundMasterDTO> secQuery = em.createQuery("SELECT new com.dto.FundMasterDTO("+" sum(appAmount), sum(redemptionPrice) from security", FundMasterDTO.class);
我收到以下错误:
Exception Description: Syntax error parsing the query [SELECT new com.dto.FundMasterDTO( sum(app_amount), sum(redemption_price) from security], line 1, column 80: syntax error at [from].
Internal Exception: MissingTokenException(inserted [@-1,0:0='<missing RIGHT_ROUND_BRACKET>',<84>,1:80] at from); nested exception is java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
如果我不使用聚合函数SUM,则一切正常。如果我删除了构造函数,那么我会得到一个列表。
答案 0 :(得分:0)
正如消息所说,你错过了一个正确的圆括号:
SELECT new com.dto.FundMasterDTO( sum(app_amount), sum(redemption_price)) ...
two parentheses here ---^