我正在尝试按照以下方式获得输出,例如' MASTHANVALI - 技术作家'
Query query = em.createQuery("select concat(upper(ename) , \" - \", deg )from employee");
但有以下错误。
Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Syntax error parsing [select concat(upper(ename) , " - ", deg )from employee].
[20, 25] The encapsulated expression is not a valid expression.
[37, 40] The expression 'deg' is not valid expression.
[54, 54] An identification variable must be provided for a range variable declaration.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1605)
at com.tutorialspoint.eclipselink.service.ScalarandAggregateFunctions.main(ScalarandAggregateFunctions.java:14) Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.JPQLException
知道怎么做吗?
答案 0 :(得分:0)
尝试用单个qoutes替换双引号,并在右括号后添加一个空格
Query query =
em.createQuery("select concat(upper(ename) , ' - ', deg ) from employee");