我在使用 JPQL 执行简单的更新查询时遇到了 ClassCastException。
下面是异常跟踪:
Caused by: java.lang.ClassCastException: org.hibernate.hql.internal.ast.tree.IdentNode cannot be cast to org.hibernate.hql.internal.ast.tree.DotNode
at org.hibernate.hql.internal.ast.tree.AssignmentSpecification.<init>(AssignmentSpecification.java:71) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.ast.HqlSqlWalker.evaluateAssignment(HqlSqlWalker.java:1133) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.ast.HqlSqlWalker.evaluateAssignment(HqlSqlWalker.java:1127) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.assignment(HqlSqlBaseWalker.java:1042) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.setClause(HqlSqlBaseWalker.java:747) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.updateStatement(HqlSqlBaseWalker.java:367) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:255) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:248) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1777) [hibernate-core-4.2.0.SP1.jar:4.2.0.SP1]
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291) [hibernate-entitymanager-4.2.0.SP1.jar:4.2.0.SP1]
at org.jboss.as.jpa.container.AbstractEntityManager.createQuery(AbstractEntityManager.java:425) [jboss-as-jpa-7.2.1.Final-redhat.jar:7.2.1.Final-redhat]
我正在执行的查询是将任务从工作池中移出:
public Boolean changeWorkpool(final TaskWorkpoolChangeRequest taskWorkpoolChangeRequest) {
final Query query = entityManager.createQuery("UPDATE Task SET workpoolId = :workpoolId"
+ " WHERE taskId= :taskId");
query.setParameter("workpoolId", taskWorkpoolChangeRequest.getWorkpoolId())
.setParameter("taskId", taskWorkpoolChangeRequest.getTaskId());
return BooleanUtils.toBoolean(query.executeUpdate());
}
有人可以透露一些有关此异常的原因吗?
提前致谢。
我是一名优秀的程序员,十分优秀!