Quando provo a correre (da Play quadro):Impossibile leggere colonna integer utilizzando Anorm
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)
}
ottengo un errore di compilazione: could not find implicit value for parameter c: anorm.Column[Integer]
Qual è il problema? Se riesco a leggere un Date
, perché non riesco a leggere un Integer
?
hai provato invece di DateTime per utilizzare Data? – Iraklis
@Iraklis - in realtà 'DateTime' funziona perfettamente. Il codice sopra funziona bene quando sostituisco 'ami [Integer] (" version ")' con '42'. – ripper234