db9010 / com.jovial.db9010 / SelectQuery / Builder / getReusable

getReusable

fun getReusable(): ReusableSelectQuery

Gives a reference to a reusable query object. This allows clients to avoid the (small) lookup overhead for a frequently-used select query.

Usage:

val stmt = (db.select(countColumn).from(TestTable) +
        " WHERE " + TestTable.testName + "=" + stringParam).getReusable()
<...>
val count = stmt.run { query ->
    query[stringParam] = testName
    query.nextOrFail()
    query[countColumn]
}

Throws IllegalStateException if this statement is not cacheable.