Yes, you do need `<reified T: Any>` for this...
# getting-started
r
Yes, you do need
<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.
Copy code
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)