Class ContextService
java.lang.Object
ch.tocco.nice2.persist.core.impl.hibernate.legacy.ContextService
- All Implemented Interfaces:
Context, AutoCloseable
-
Nested Class Summary
Nested classes/interfaces inherited from interface Context
Context.Tx -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddContextListener(ContextListener listener) voidAdds anEntityFacadeListenerto a global list of listeners that are used for allEntityManagersthis context creates.voidAdds anEntityListenerto be used in allEntityManagers.beginTx()voidvoidclear()Clear all cached data from this context.voidclose()compileQuery(String query) Compile the specified query string to an executable query.getAttribute(String key) getEntityManager(String model) getId()@Nullable IntegergetTx()booleanbooleanvoidvoidremoveContextListener(ContextListener listener) voidRemoves anEntityFacadeListenerfrom the list of global listeners (previously added byContext.addEntityFacadeListener(EntityFacadeListener)voidRemoves anEntityListenerthat was added usingContext.addEntityListener(EntityListener).voidresume()Bind the context to the current thread.voidsetAttribute(String key, Object value) voidsetQueryTimeout(int queryTimeout) voidsuspend()Unbind the context from the current thread.tx()unwrap()
-
Constructor Details
-
ContextService
-
-
Method Details
-
getPersistenceSession
- Specified by:
getPersistenceSessionin interfaceContext
-
getId
-
getTx
- Specified by:
getTxin interfaceContext- Returns:
- The
TransactionManagerfor this context.
-
tx
-
getEntityManager
- Specified by:
getEntityManagerin interfaceContext- Parameters:
model- The name of the entity type.- Returns:
- The entity manager of the entity type.
-
getCacheControl
- Specified by:
getCacheControlin interfaceContext- Returns:
- CacheControl allows manual invalidating of cached entities.
-
compileQuery
Description copied from interface:ContextCompile the specified query string to an executable query.- Specified by:
compileQueryin interfaceContext- Parameters:
query- The query string.- Returns:
- The executable query.
- Throws:
PersistException
-
addContextListener
- Specified by:
addContextListenerin interfaceContext
-
removeContextListener
- Specified by:
removeContextListenerin interfaceContext
-
addCommitListener
- Specified by:
addCommitListenerin interfaceContext
-
removeCommitListener
- Specified by:
removeCommitListenerin interfaceContext
-
suspend
-
resume
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceContext
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceContext- Returns:
- true if the underlying
Sessionis closed
-
isCurrent
-
checkCurrent
public void checkCurrent()- Specified by:
checkCurrentin interfaceContext
-
setAttribute
- Specified by:
setAttributein interfaceContext
-
getAttribute
- Specified by:
getAttributein interfaceContext
-
setQueryTimeout
public void setQueryTimeout(int queryTimeout) - Specified by:
setQueryTimeoutin interfaceContext
-
getQueryTimeout
- Specified by:
getQueryTimeoutin interfaceContext
-
addEntityListener
Description copied from interface:ContextAdds anEntityListenerto be used in allEntityManagers.- Specified by:
addEntityListenerin interfaceContext
-
removeEntityListener
Description copied from interface:ContextRemoves anEntityListenerthat was added usingContext.addEntityListener(EntityListener).- Specified by:
removeEntityListenerin interfaceContext
-
addEntityFacadeListener
Description copied from interface:ContextAdds anEntityFacadeListenerto a global list of listeners that are used for allEntityManagersthis context creates.- Specified by:
addEntityFacadeListenerin interfaceContext
-
removeEntityFacadeListener
Description copied from interface:ContextRemoves anEntityFacadeListenerfrom the list of global listeners (previously added byContext.addEntityFacadeListener(EntityFacadeListener)Be sure to perform this in a finally clause so that the remove is not skipped!
- Specified by:
removeEntityFacadeListenerin interfaceContext
-
unwrap
-
beginTx
-
clear
-
createSqlWriter
- Specified by:
createSqlWriterin interfaceContext- Returns:
- a
SqlWriterconfigured for the current database.
-
getPersistenceService
- Specified by:
getPersistenceServicein interfaceContext
-