Search code examples
scalaplayframeworkplayframework-2.0anorm

get java.math.BigInteger from executeInsert() using Anorm in scala


The problem is that executeInsert returns the Long type result But i want the executeInsert to return the java.math.BigInteger type of result.Since, the userId in database is of 20 digit long. Now, i am trying to parse the executeInsert result to java.math.BigInteger using ResultSetParser. Could anyone write solution:

val id=SQL(
  """
    INSERT INTO registration(userId,name) 
       VALUES (1,"sam")
  """
).executeInsert();

Solution

  • Yes.!! I found the solution. It works:

    val id=SQL(
      """
    INSERT INTO registration(userId,name) 
       VALUES (1,"sam")
      """
    ).executeInsert(scalar[BigInteger].single);