当我尝试运行时(从 Play Framework):
import play.api.db.DB
import anorm._
import org.joda.time.DateTime
import AnormExtensions._ // http://stackoverflow.com/a/11975107/11236
import play.api.Play.current
import java.util.Date
var stream = SQL("SELECT amiId, created, version FROM Amis WHERE created = {maxCreated}")
.on("maxCreated" -> new Date(maxCreated.getMillis))
.apply()
val map: Stream[Ami] = stream.map { ami =>
val s: String = ami[String]("amiId")
val date: Date = ami[Date]("created")
// The following line throws a compilation error
var version: Integer = ami[Integer]("version")
new Ami(s, new DateTime(date), version)
}
我得到一个编译错误:could not find implicit value for parameter c: anorm.Column[Integer]
这里有什么问题?如果我可以阅读 a Date
,为什么我不能阅读 a Integer
?