关联字段不能在更新项目的路径表达式Spring Data JPA中使用

时间:2018-07-28 20:08:52

标签: spring spring-data-jpa jpa-2.1

我正在使用Spring Data JPA和JPQL查询。尝试执行以下更新查询时,出现以下错误。我们如何解决这个问题?

查询:

@Query("UPDATE EmployeeSrc e SET e.employeeStat.employeeStatStatCd =?1, e.UpdtDt =?2, e.UpdtUserId =?3 "
            + "WHERE e.employeeStat.employeeStatStatCd =?4 AND e.EmpployeeNam =?5")
    public void updateXXXXXXXXX(Long employeeStatStatCd, Date UpdtDt, String lstUpdtUserId, 
            Long employeeStatStatCd, String employeeName);

错误:

Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Problem compiling [UPDATE EmployeeSrc e SET e.EmployeeStat.EmployeeStatCd =?1, e.UpdtDt =?2, e.UpdtUserId =?3 WHERE e.EmployeeStat.EmployeeStatCd =?4 AND e.EmployeeName =?5]. 
[20, 49] An association field cannot be used in an update item's path expression.
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:155)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:347)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:278)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:163)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:116)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:102)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:86)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1614)
    ... 61 more

0 个答案:

没有答案