1
我在2.4版本中设置了一个普通的Play Framework项目 - Java。创建自定义模型对象并返回它们的列表非常简单。我坚持使用ebean的对象。使用Play Framework在数据库中查找单个对象
但是,如何使用GET返回单个对象?
路线:
GET /payments/:id controllers.Application.getPayment(id: Long)
而控制器试图找对象byId:
public Result getPayment(Long id) {
Payment payment = Payment.find.byId(id);
return ok(toJson(payment));
}
但我的应用程序不知道是什么find
是。
我跟着官方Play documentation指令。
编辑:我Payment.class
package models;
import com.avaje.ebean.Model;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Payment extends Model {
@Id
Long id;
String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
请您出示付款类 – cosmolev
@cosmolev我更新我的帖子:) – Marcel