I'm trying to assign office for employees with same department. I'm gettin this error. What's the problem here ?
"org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [update com.example.macademiaproject.model.Employee u set u.office = :office where u.department = :department]; nested exception is java.lang.IllegalStateException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [update com.example.macademiaproject.model.Employee u set u.office = :office where u.department = :department]",
Query :
@Modifying
@Query("update Employee u set u.office = :office where u.department = :department")
List <Employee> assignOffice (@Param("office") String office,
@Param("department") String department);
ServiceImpl :
@Override
public List<Employee> assignOffice(String department,String office) {
List<Employee> employees = employeeRepository.assignOffice(office,department);
return employees;
}
Controller :
@GetMapping(path="/assign")
public ResponseEntity<List<Employee>> assignOffice(@RequestParam("office") String office,
@RequestParam("department") String department){
return ResponseEntity.ok(employeeService.assignOffice(office,department));
}