我刚开始玩游戏,我修改了执行 SQL 读取的方式,现在出现以下错误:
[Exception: DB plugin is not registered.]
我有这个类的代码是:
package models
import play.api.db._
import play.api.Play.current
import anorm._
case class Housing(id: Long, rent: String, address: String, street0: String, street1: String, neighbourhood: String)
object Housing {
def all(): List[Housing] = DB.withConnection { implicit c =>
SQL("select * from housing")().map { row =>
Housing(row[Long]("id"), row[String]("rent"), row[String]("address"), row[String]("street0"),
row[String]("street1"), row[String]("neighbourhood"))
}.toList
}
def create(rent: String, address: String, street0: String, street1: String, neighbourhood: String) {}
def delete(id: Long) {}
}
我不确定这是否是最好的方法,但使用 ~ 链似乎最终会复制一堆东西。