mardi 21 avril 2015

СonvertIng Biginteger to long causes error

I am moving a playframework app database from PostgreSQL to MySQL.

And I get this error when launching the app:

Cannot convert 126: class java.math.BigInteger to Long for column ColumnName(Speaker.id,Some(id))

It seems to come from there:

def listAll: List[Speaker] = DB.withConnection {implicit c =>
SQL("SELECT * FROM Speaker;")
  .as(speakerParser *)}<---

Here is the code of the speackerParser:

private val speakerParser: RowParser[Speaker] = {
  get[Long]("id") ~
  get[String]("firstName") ~
  get[String]("lastName") ~
  get[String]("title") ~
  get[String]("team") ~
  get[String]("organisation") ~
  get[String]("email") map {
    case id ~ firstName ~ lastName ~ title ~ team ~ organisation ~ email => Speaker(id, firstName, lastName, title, team, organisation, email)
  }}

And the column wich cause my troubles is id:

Table: Speaker
Columns:
id  bigint(20) UN AI PK
title   varchar(20)
firstName   varchar(255)
lastName    varchar(255)
email   varchar(255)
team    varchar(255)
organisation    varchar(255)

This code is not from me but I need to modify it.

I am new to postgre, scala and Play so I may forget something really simple.

Aucun commentaire:

Enregistrer un commentaire