I am using a Derby database with Anorm in Play 2.0.2. Even though no column has a BigDecimal field, I get the following error when inserting into a table.
Execution exception [[RuntimeException: TypeDoesNotMatch(Cannot convert 1:class java.math.BigDecimal to Long for column .1)]]
If I look in the table, I can see that my data has been entered so I infer that the problem has to do with returning the new key. But I clearly declare the key as a bigint–why the complaint about BigDecimal?
It turns out that Derby always returns the key as a
BigDecimal–even if they key is defined otherwise. The solution is to use a customResultSetParserto handle theBigDecimal. The id column returned is named “1”.Or, putting it all together.
You can then map it to a
Longwithmap (_.longValue).