0
我正在使用Playframework編寫TodoList應用程序。我想更新一個任務,但不知道如何使用JPA更新(我只是從PHP使用Zend Framework而不熟悉Hibernate)。 我有編輯頁面的網址,例如:http://localhost:9000/TaskList/edit?id=2如何使用Playframework更新Mysql條目
其操控:
public static void edit(Long id) {
models.TaskList selectedTask = models.TaskList.findById(id);
render(selectedTask);
}
其模型
@Entity
public class TaskList extends Model {
public String task;
public int priority;
public String category;
public String taskStatus;
public TaskList(String task, int priority, String category, String taskStatus) {
this.task = task;
this.priority = priority;
this.category = category;
this.taskStatus = taskStatus;
}
我需要id屬性模型(在數據庫中,我有id字段)? 如果沒有,當模型沒有指定id時如何更新?
謝謝大家。
非常感謝你,這正好解決了我的問題。 – 2011-05-27 09:30:33
不客氣,如果你厭倦了JPA,試試像錫耶那這樣的替代品,它有時會帶來一絲氧氣;) – mandubian 2011-05-27 09:36:06