Ruckus
01/05/2017, 8:36 PM<reified T: Any>
for this to work.
If you can't do that, you'll have to pass in the class type to the function.
public fun <T> Connection.testQuery(sqlString: String, clazz: Class<T>) : T? {
try {
val connection: Connection = sql2o.open()
val results = connection.createQuery(sqlString).executeAndFetch(clazz)
return results
} catch (e: Exception) {
println(e.toString())
return null
}
}
called with connection.testQuery("SQL", DAO::class.java)