将文本区域内容存储在ebean数据库中



我觉得这个问题可能有点愚蠢——我正在进行我的第一个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()始终为true。。

@textarea(entryForm("report:"))更改为@textarea(entryForm("text"))(..来说明问题,我实际上想填充3个Entry字段中的哪一个)甚至会导致PersistenceException:

"类型[class models.Entry]不是注册的实体?如果您没有明确列出要使用Ebean的实体类,将在类路径中搜索它们。如果实体在Jar中,请检查Ebean.properties文件中的Ebean.search.Jar属性或检查ServerConfig.addJar()。]">

以ToDoList为例,除了让它扩展play.db.ebean.Model之外,我无法检测如何注册实体!

我想您忘记了Entry类上的@Entity注释。

最新更新