|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.picocontainer.persistence.hibernate.AbstractSessionDecorator
org.picocontainer.persistence.hibernate.ScopedSession
public final class ScopedSession
Session implementation which allows request scoping while supporting lifecycle events. If you register this component within either a request PicoContainer or a request-scoped storage object, then this component will close sessions whenever stop() is called by the container, and is reusable until dispose() is called.
This allows for the "One Session Per Request" pattern often used in Hibernate.
| Constructor Summary | |
|---|---|
ScopedSession(org.hibernate.SessionFactory factory)
Creates a ScopedSession with factory and null interceptor |
|
ScopedSession(org.hibernate.SessionFactory factory,
org.hibernate.Interceptor interceptor)
Creates a ScopedSession with factory and interceptor |
|
| Method Summary | |
|---|---|
Connection |
close()
* |
void |
dispose()
|
protected void |
finalize()
Add some insurance against potential memory leaks. |
org.hibernate.Session |
getDelegate()
Obtain hibernate session in lazy way. |
org.hibernate.Interceptor |
getInterceptor()
Returns the current interceptor. |
org.hibernate.SessionFactory |
getSessionFactory()
* |
int |
hashCode()
* |
void |
invalidateDelegate()
Perform actions to dispose "burned" session properly. |
void |
setInterceptor(org.hibernate.Interceptor interceptor)
Sets a new hibernate session interceptor. |
void |
start()
|
void |
stop()
|
String |
toString()
* |
| Methods inherited from class org.picocontainer.persistence.hibernate.AbstractSessionDecorator |
|---|
beginTransaction, cancelQuery, clear, connection, contains, createCriteria, createCriteria, createCriteria, createCriteria, createFilter, createQuery, createSQLQuery, delete, delete, disableFilter, disconnect, enableFilter, evict, flush, get, get, get, get, getCacheMode, getCurrentLockMode, getEnabledFilter, getEntityMode, getEntityName, getFlushMode, getIdentifier, getNamedQuery, getSession, getStatistics, getTransaction, handleException, isConnected, isDirty, isOpen, load, load, load, load, load, lock, lock, merge, merge, persist, persist, reconnect, reconnect, refresh, refresh, replicate, replicate, save, save, saveOrUpdate, saveOrUpdate, setCacheMode, setFlushMode, setReadOnly, update, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ScopedSession(org.hibernate.SessionFactory factory)
null interceptor
factory - session factory to create the session
public ScopedSession(org.hibernate.SessionFactory factory,
org.hibernate.Interceptor interceptor)
factory - session factory to create the sessioninterceptor - interceptor to use with created session| Method Detail |
|---|
public org.hibernate.SessionFactory getSessionFactory()
getSessionFactory in interface org.hibernate.SessiongetSessionFactory in class AbstractSessionDecoratorpublic org.hibernate.Session getDelegate()
getDelegate in class AbstractSessionDecoratorpublic Connection close()
Because this implementation decorates a delegate session, it removes the delegate session, but it does allow re-referencing once close() has been called. It simply grabs a new Hibernate session.
close in interface org.hibernate.Sessionclose in class AbstractSessionDecoratorpublic void invalidateDelegate()
AbstractSessionDecorator
invalidateDelegate in class AbstractSessionDecoratorpublic org.hibernate.Interceptor getInterceptor()
public void setInterceptor(org.hibernate.Interceptor interceptor)
throws IllegalStateException
interceptor - the Interceptor to apply to this session.
IllegalStateException - if this session has already been utilized
after creation.
protected void finalize()
throws Throwable
finalize in class ObjectThrowablepublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic void start()
Currently does nothing. Session is lazily created .
start in interface org.picocontainer.Startablepublic void stop()
Closes and invalidates any sessions that are still open.
stop in interface org.picocontainer.Startablepublic void dispose()
Prevents any further utilization once called.
dispose in interface org.picocontainer.Disposable
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||