facilejdbc
facilejdbc copied to clipboard
'ScopedValue' for implicit connection
Add a ScopedValue for Connections, which allows to use Query objects without an explicit connection parameter.
public final class Query {
public <T> T as(
final ResultSetParser<? extends T> parser,
final Connection conn
) {
// ...
}
// This method uses the transaction given by the 'ScopedValue'.
public <T> T as(final ResultSetParser<? extends T> parser) {
return as(parser, Transaction.connection());
}
}