playframework/playframework — pull request #2450 by cchantep (2014-03-05 22:05:35+00:00)
Title: Null handling for Java object representing primitive type as parameter

As methods on `java.sql.PreparedStatement` for primitive types (e.g. boolean, integer, ...) don't accept object equivalent (e.g. `java.lang.Integer` for integer/`int`), autoboxing raise `NullPointerException` when calling statement setter with null (e.g. `Integer intObj = null; stmt.setInt(index, intObj);`).

This PR fixes that, at runtime by using `.setNull(index, JDBC_TYPE)`.

I tend to think `ToStatement` implicit for those Java type should better be defined with `with NotNull`, for following reasons.
- It would be handled by compiler (not finding the implicit if `null`).
- It's more coherent with what's done mapping from SQL (`Column` mapping), where NULL should be explicitly handle (making it optional or not).
- It avoid to use `java.sql.Types` as some constant are not really clear.