【发布时间】:2015-02-03 15:06:07
【问题描述】:
我在 JPQL 中遇到问题。我有两个像下面这样的实体
class Employee{
private Long id;
private String name;
private Department department;
public void setId(Long id){
this.id = id;
}
public void setName(String name){
this.name = name;
}
public void setDepartment(Department department){
this.department = department
}
public Long getId(){
return this.id;
}
public String getName(){
return this.name;
}
public Department getDepartment(){
return this.department;
}
}
还有……
class Department{
private Long id;
private String name;
public void setId(Long id){
this.id = id;
}
public void setName(String name){
this.name = name;
}
public Long getId(){
return id;
}
public String getName(){
return name;
}
}
现在我需要更新Employee 的部门。我试过下面的查询。
update Employee e set e.department.id = 'XXX' where e.id in (?1);
这给了异常
java.lang.IllegalStateException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations.
你能指导我吗,我该如何解决这个问题?
干杯, 泰迦。
【问题讨论】:
标签: spring spring-data spring-data-jpa jpql