fix for testing autogenerated keys

it seems that `ResultSet#getObject` doesn't reliably return an appropriate
datatype when fetching auto-generated keys after an insert statement
eg for Derby, even if the autogenerated column has type `INT` or `BIGINT`,
a `java.util.BigDecimal` is still returned.

The change works around this problem by using one of the `ResultSet#get<X>`
methods to cast the result to the appropriate datatype, and adds tests for
this problem.