Package org.jdbi.v3.core
Interface HandleScope
public interface HandleScope
Jdbi manages Handles to allow transaction nesting and extension
objects to share the same handle as long as they are within a specific scope.
The default scope is "per thread", which is managed by the default implementation of this interface.
It is possible to provide a different implementation by calling
The default scope is "per thread", which is managed by the default implementation of this interface.
It is possible to provide a different implementation by calling
Jdbi.setHandleScope(HandleScope)
to support e.g. structured concurrency in modern Java or Kotlin coroutines.-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove a currentassociation.get()Returns aHandleSupplierthat provides aHandlein the given context.voidset(HandleSupplier handleSupplier) Associate aHandleSupplierwith the current scope.default voidAssociate aHandlewith the current scope.static HandleScope
-
Method Details
-
threadLocal
-
get
HandleSupplier get()Returns aHandleSupplierthat provides aHandlein the given context.- Returns:
- A handle object or null.
-
set
Associate aHandleSupplierwith the current scope.- Parameters:
handleSupplier- AHandleSupplierobject. Must not be null.
-
set
Associate aHandlewith the current scope.- Parameters:
handle- AHandleobject. Must not be null.
-
clear
void clear()
-