【发布时间】:2012-10-11 23:29:17
【问题描述】:
我认为这个问题可能有点愚蠢 - 我正在开发我的第一个 Play 项目,因此我仍在努力了解软件的概况;)
嗯,我有一个包含文本区域的页面。用户应该能够在那里输入文本并将其永久存储在标准 ebean 数据库中。 但是存储永远不起作用,我找不到原因!
这是数据库对象的类定义:
public class Entry extends Model {
@Required
public String text;
public String studentName;
@Id
public long id;
public static Finder<Long, Entry> finder = new Finder<Long, Entry>( Long.class, Entry.class);
public static Entry getMe(Long id) {
return finder.byId(id);
}
public static void saveMe(Entry toDataBase) {
toDataBase.save();
}
// ....
}
这里是文本区域:
@(entryForm: Form[Entry])
@import helper._
@main("xy") {
<h1>report for @entryForm("studentName")</h1>
@form(routes.Application.storeReport()) {
@textarea(entryForm("report:"))
<input type="submit" value="Store Report">
}
}
在Application.storeReport() 方法中entryForm.bindFromRequest().hasErrors() 总是为真..
并将@textarea(entryForm("report:")) 更改为@textarea(entryForm("text"))(..告诉我,我真正想要填写的 3 个 Entry 字段中的哪一个)甚至会导致 PersistenceException:
“类型 [class models.Entry] 不是注册实体?如果您没有明确列出要使用的实体类,Ebean 将在类路径中搜索它们。如果实体在 Jar 中,请检查 ebean。 ebean.properties 文件中的 search.jars 属性或检查 ServerConfig.addJar().]"
以ToDoList example 为导向,除了让它扩展 play.db.ebean.Model 之外,我无法检测到如何注册一个实体!
【问题讨论】:
标签: playframework playframework-2.0 ebean