facilejdbc icon indicating copy to clipboard operation
facilejdbc copied to clipboard

'ScopedValue' for implicit connection

Open jenetics opened this issue 4 months ago • 0 comments

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());
    }
}

jenetics avatar Aug 06 '25 19:08 jenetics