我是Play框架的新手。我一直在使用play framework 2.5编写java中的基本创建,查找,删除和更新Employee记录。我在更新记录时遇到问题。这是我在Controller文件中的代码,我想明智地替换员工ID的部门。我知道如何提取记录但不知道如何更新记录。
public class EmployeeController extends Controller {
public Result addEmployee() {
Employee newEmployee = new Employee(100001L, "Test", "User", "HR");
newEmployee.save();
return ok("Employee Created!");
}
public Result addEmployee1() {
Employee newEmployee = new Employee(100002L, "Test", "User2", "DEPT001");
newEmployee.save();
return ok(Json.toJson(newEmployee));
}
public Result UpdateEmployee() {
Employee oldrecord = Employee.find.byId(100002L);
}
}