DefaultSessionProvider
The SessionProvider for an application that runs its own transactions, binding the current one to the thread that started it.
Outside a transaction, every operation borrows a session from dataSource and gives it back when it is done. That is as cheap as it sounds: the session itself is a handful of allocations over the connection, and giving it back costs no round trip unless it registered a LISTEN or left a transaction open.
Where something else owns the transaction - Spring, most obviously - this is the wrong provider; that one finds the session where the framework put it rather than on a ThreadLocal of its own.
Parameters
Where connections come from. Not closed by close; whoever built the pool owns it.
Functions
Runs block with a transaction open, committing when it returns and rolling back when it throws.