I cannot parse float value in play framework, It gives me a compilation error. So from database I get value as float but it can not determine value as float and gives error of anorm of float.
Error it gave is is like
My code is like :
package model
import anorm._
import play.api.db._
import play.api.Play.current
case class Contact(id: String, VehiclePositionLattitude: Double,
VehiclePositionLongitude: Any)
object Contact {
def all={
DB.withConnection { implicit connection=>
SQL("Select VehicleJourneyUID,VehiclePositionLattitude,VehiclePositionLongitude
from csv_output where VehicleJourneyUID in (31356)")().map{ row=>
Contact(
id=row[String]("VehicleJourneyUID"),
VehiclePositionLattitude=row[Double]("VehiclePositionLattitude"),
VehiclePositionLongitude=row[Float]("VehiclePositionLongitude")
)
}.toList
}
}
}
Did you try to use implicit Reads and Writes for Float? or how about validate it with BigDecimal data type even it appears as Float at SQL Database.
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.