Package ru.vyarus.guicey.jdbi3.unit
Class UnitManager
- java.lang.Object
-
- ru.vyarus.guicey.jdbi3.unit.UnitManager
-
- All Implemented Interfaces:
jakarta.inject.Provider<org.jdbi.v3.core.Handle>
@Singleton public class UnitManager extends java.lang.Object implements jakarta.inject.Provider<org.jdbi.v3.core.Handle>Manages JDBIHandlefor current unit of work. This handle must be used by all JDBI proxies. Unit of work is thread-bound (all actions in one thread participate in one unit of work). It is not intended to be used directly (only in really rare cases when manual unit required without opening transaction).Raw provider may be injected to obtain current handle:
@Inject Provider<Handle>. In all other cases transaction annotation must be used to wrap code into unit of work using guice aop.- Since:
- 31.08.2018
- See Also:
for manual transaction definition
-
-
Constructor Summary
Constructors Constructor Description UnitManager(org.jdbi.v3.core.Jdbi jdbi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginUnit()Starts unit of work.voidendUnit()Finish unit of work.org.jdbi.v3.core.Handleget()booleanisUnitStarted()
-
-
-
Method Detail
-
get
public org.jdbi.v3.core.Handle get()
- Specified by:
getin interfacejakarta.inject.Provider<org.jdbi.v3.core.Handle>
-
isUnitStarted
public boolean isUnitStarted()
- Returns:
- true if unit of work started (and handle could be obtained), false otherwise
-
beginUnit
public void beginUnit()
Starts unit of work.- Throws:
java.lang.IllegalStateException- if unit of work already started
-
endUnit
public void endUnit()
Finish unit of work. Note: does not commit transaction, but only close context handle.- Throws:
java.lang.IllegalStateException- when no opened unit of work
-
-