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 TypeMethodDescriptionvoid
clear()
Remove a currentassociation
.get()
Returns aHandleSupplier
that provides aHandle
in the given context.void
set
(HandleSupplier handleSupplier) Associate aHandleSupplier
with the current scope.default void
Associate aHandle
with the current scope.static HandleScope
-
Method Details
-
threadLocal
-
get
HandleSupplier get()Returns aHandleSupplier
that provides aHandle
in the given context.- Returns:
- A handle object or null.
-
set
Associate aHandleSupplier
with the current scope.- Parameters:
handleSupplier
- AHandleSupplier
object. Must not be null.
-
set
-
clear
void clear()
-