0

I try to fill a form with the values of System

  def edit(id: Long) = IsAuthenticated { username => implicit request =>
    User.findByEmail(username).map { user =>
      System.findById(id).map { system =>
      Ok(html.systems.editForm(id, systemForm.fill(system), Person.options, user))
    }.getOrElse(NotFound)
    }.getOrElse(Forbidden)
  }

but some of 'system' values are java.math.BigDecimal

 val systemForm = Form(
    mapping(
      "id" -> ignored(NotAssigned:Pk[BigDecimal]),
      "sys_name" -> nonEmptyText,
      "sys_desc" -> nonEmptyText,
      "sys_owner1_id" -> longNumber,
      "sys_owner2_id" -> optional(longNumber)
    )(System.apply)(System.unapply)
  )

and it says :

type mismatch; found : (anorm.Pk[java.math.BigDecimal], String, String, String, Option[String], java.math.BigDecimal, Option[java.math.BigDecimal]) => models.System required: (anorm.Pk[java.math.BigDecimal], String, String, Long, Option[Long]) => ? 

how can i handle this?

mbrambley
  • 245
  • 3
  • 10

1 Answers1

0

Looks like problem in anorm or somewhere near.

As you may see from error description sys_owner1_id and sys_owner2_id are BigIntegers in query result, but declared as long in form.

I am not familiar with anorm, but solution is to declare these ids as long in anorm, or declare them as BigInteger in form mapping or convert from BigInteger to long in your query.

1esha
  • 1,722
  • 11
  • 17
  • thanks - im forced to use java BigDecimal as that what Oracle JDBC uses for number types - but the form helpers wont work with them... i cant thinkk of a way round it. I wish they put on the website you cant use play with Oracle before I began. I spoke to someone at typesafe but they just said ditch anorm and use SLICK - but theres hardly any doc and its not integrated into play yet – mbrambley Sep 05 '13 at 16:01