In Kotlin I would just solve it once and be done with the issue forever with this:
fun <K : Any> ResultSet.getNullable(columnLabel: String, type: KClass<K>): K? =
this.getObject(columnLabel, type.java)
So later you can just do this:
rs.getNullable("ID_PARENT", Int::class)
I guess if you want you could also do this too
fun <K> ResultSet.getNullable(columnLabel: String, type: Class<K>): K? =
this.getObject(columnLabel, type)
So you can just do this:
rs.getNullable("ID_PARENT", Int::class.java)
Or better still make both methods available if you happen to be dealing with developers that can't agree on even the simplest of things.
fun <K : Any> ResultSet.getNullable(columnLabel: String, type: KClass<K>): K? =
this.getNullable(columnLabel, type.java)
fun <K> ResultSet.getNullable(columnLabel: String, type: Class<K>): K? =
this.getObject(columnLabel, type)
Edit: if the library is still being fussy you can finally do something like:
rs.getNullable("ID_PARENT", String::class)?.let {FOO.valueOf(it) }