Class ContextManagerAdapter
java.lang.Object
ch.tocco.nice2.persist.core.impl.hibernate.legacy.ContextManagerAdapter
- All Implemented Interfaces:
ContextManager
Manages and creates
Context
instances.
At most one Context
can be bound to a thread at the same time.
The 'current' session/context is defined by the SessionFactoryManager
(which in turn
uses the ManagedSessionContext
to store the current session).-
Constructor Summary
ConstructorDescriptionContextManagerAdapter
(TypeManager typeManager, SessionFactoryManager sessionFactoryManager, PersistenceService persistService, NiceDataModel dataModel, QueryCompiler queryCompiler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Clear and close the implicit context.Create a new context and attach it to the current thread.createNewContext
(Integer queryTimeout) createNewContext
(Connection connection) Create a new context using an existing connection.createNewContext
(Connection connection, Integer socketTimeout) void
setThreadContext
(@Nullable Context ctx) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.persist.core.api.ContextManager
newContext
-
Constructor Details
-
ContextManagerAdapter
public ContextManagerAdapter(TypeManager typeManager, @Lazy SessionFactoryManager sessionFactoryManager, @Lazy PersistenceService persistService, @Lazy NiceDataModel dataModel, @Lazy QueryCompiler queryCompiler)
-
-
Method Details
-
createNewContext
Description copied from interface:ContextManager
Create a new context and attach it to the current thread.- Specified by:
createNewContext
in interfaceContextManager
-
createNewContext
- Specified by:
createNewContext
in interfaceContextManager
-
createNewContext
Description copied from interface:ContextManager
Create a new context using an existing connection. This can be useful in special circumstances when a context needs to use the same transaction as an already existing connection. Note: The connection is not closed when the context is closed!- Specified by:
createNewContext
in interfaceContextManager
-
createNewContext
- Specified by:
createNewContext
in interfaceContextManager
-
setThreadContext
- Specified by:
setThreadContext
in interfaceContextManager
-
getThreadContext
- Specified by:
getThreadContext
in interfaceContextManager
-
clearImplicitContext
public void clearImplicitContext()Description copied from interface:ContextManager
Clear and close the implicit context. Should be called at the end of a test or request. Can also called when the implicit context is no longer needed to release the database connection.- Specified by:
clearImplicitContext
in interfaceContextManager
-
addContextCreationListener
- Specified by:
addContextCreationListener
in interfaceContextManager
-
removeContextCreationListener
- Specified by:
removeContextCreationListener
in interfaceContextManager
-