|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectit.amattioli.dominate.hibernate.HibernateSessionManager
public class HibernateSessionManager
Can be used to retrieve a Hibernate session with a defined life-cycle.
Two different life-cycles are possible: long running and thread local
Sessions with a thread local life cycle are created and destroyed in the current thread, wile long-running sessions, at the end of the current thread, disconnect their database connection and can be reconnected in a new thread.
| Constructor Summary | |
|---|---|
HibernateSessionManager()
|
|
HibernateSessionManager(SessionMode sessionMode)
Creates a new session managers |
|
| Method Summary | ||
|---|---|---|
static void |
disconnectAll()
Terminates all the sessions used in the current thread. |
|
static String |
getCfgResource()
|
|
static org.hibernate.cfg.Configuration |
getConfiguration()
Retrieves the Configuration object that will be used for Hibernate configuration. |
|
org.hibernate.Session |
getSession()
Retrieves the session managed by this session manager. |
|
|
getSession(Class<S> sessionClass)
Retrieves a session associated with this SessionManager. |
|
static org.hibernate.SessionFactory |
getSessionFactory()
Retrieves the Hibernate SessionFactory that will be used to create new sessions. |
|
SessionMode |
getSessionMode()
Retrieves the SessionMode associated with this SessionManager |
|
boolean |
hasSessionMode(SessionMode sMode)
Check if this SessionManager has a certain SessionMode |
|
boolean |
isReleased()
Check if this SessionManager has been released. |
|
void |
release()
Informs this manager that it will not be used any more so it can definitely close the session it manages |
|
void |
reset()
Close the current session and prepare to open a new one when the getSession()
method is called. |
|
static void |
setCfgResource(String cfgResource)
Set the name of the resource xml file from which the Hibernate configuration should be read. |
|
static void |
setConfiguration(org.hibernate.cfg.Configuration newCfg)
The Configuration object that will be used for Hibernate configuration. |
|
void |
setSessionMode(SessionMode sessionMode)
|
|
org.apache.commons.collections.Closure |
transactionalClosure(org.apache.commons.collections.Closure toBeDone)
Decorate a closure so that it will be executed in a transactional context. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HibernateSessionManager()
public HibernateSessionManager(SessionMode sessionMode)
sessionMode - the life cycle of the managed session| Method Detail |
|---|
public static void setConfiguration(org.hibernate.cfg.Configuration newCfg)
newCfg - the Configuration object that will be used for Hibernate
configurationpublic static org.hibernate.cfg.Configuration getConfiguration()
setConfiguration(Configuration) that object will be returned,
otherwise a new default Configuration object will be created.
public static String getCfgResource()
public static void setCfgResource(String cfgResource)
cfgResource - public static org.hibernate.SessionFactory getSessionFactory()
public static void disconnectAll()
Session.disconnect() method
will be called, so they can be re-opened, while on thread local
sessions the Session.close() method will be called and
they cannot be used again.
public void setSessionMode(SessionMode sessionMode)
setSessionMode in interface SessionManagerpublic SessionMode getSessionMode()
SessionManagerSessionMode associated with this SessionManager
getSessionMode in interface SessionManagerSessionMode associated with this SessionManagerpublic boolean hasSessionMode(SessionMode sMode)
SessionManagerSessionMode
hasSessionMode in interface SessionManagersMode - the SessionMode to check
SessionModepublic boolean isReleased()
SessionManager
isReleased in interface SessionManager#release()}public <S> S getSession(Class<S> sessionClass)
SessionManager
getSession in interface SessionManagersessionClass - the class of the needed session
public org.hibernate.Session getSession()
public void release()
release in interface SessionManagerpublic void reset()
getSession()
method is called.
reset in interface SessionManagerpublic org.apache.commons.collections.Closure transactionalClosure(org.apache.commons.collections.Closure toBeDone)
SessionManager
transactionalClosure in interface SessionManagertoBeDone - the closure to be decorated
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||