Play + Anorm + Postgres - load json value into a case class
The solution is just to add the following:
implicit val socialDataToStatement = new ToStatement[MyClass] { def set(s: PreparedStatement, i: Int, myClass: MyClass): Unit = { val jsonObject = new org.postgresql.util.PGobject() jsonObject.setType("json") jsonObject.setValue(Json.stringify(Json.toJson(myClass))) s.setObject(i, jsonObject) }}
and:
implicit object MyClassMetaData extends ParameterMetaData[MyClass] { val sqlType = "OTHER" val jdbcType = Types.OTHER}