|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.elca.el4j.services.persistence.hibernate.OpenSessionInServiceInterceptor
public class OpenSessionInServiceInterceptor
This interceptor is similar to OpenSessionInViewInterceptor
, but can
also be used e.g. for batch job processing where no HTTP requests are used.
Another use case is to take this class as a replacement for
HibernateInterceptor
, now having more control over the flush mode and
a single session feature.
Constructor Summary | |
---|---|
OpenSessionInServiceInterceptor()
|
Method Summary | |
---|---|
protected void |
closeSession(Session session)
Close the given Session. |
FlushMode |
getFlushMode()
|
protected Session |
getSession(SessionFactory sessionFactory)
Get a Session for the SessionFactory that this filter uses. |
SessionFactory |
getSessionFactory()
|
Object |
invoke(org.aopalliance.intercept.MethodInvocation invocation)
|
boolean |
isSingleSession()
|
void |
setFlushMode(FlushMode flushMode)
|
void |
setSessionFactory(SessionFactory sessionFactory)
|
void |
setSingleSession(boolean singleSession)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OpenSessionInServiceInterceptor()
Method Detail |
---|
public boolean isSingleSession()
public void setSingleSession(boolean singleSession)
singleSession
- the singleSession to setpublic SessionFactory getSessionFactory()
public void setSessionFactory(SessionFactory sessionFactory)
sessionFactory
- the sessionFactory to setpublic FlushMode getFlushMode()
public void setFlushMode(FlushMode flushMode)
flushMode
- the flushMode to setpublic Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable
invoke
in interface org.aopalliance.intercept.MethodInterceptor
Throwable
protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException
The default implementation delegates to the
SessionFactoryUtils.getSession
method and sets the
Session
's flush mode to "NEVER".
Can be overridden in subclasses for creating a Session with a custom entity interceptor or JDBC exception translator.
sessionFactory
- the SessionFactory that this filter uses
DataAccessResourceFailureException
- if the Session could not be createdSessionFactoryUtils.getSession(SessionFactory,
boolean)
,
FlushMode.COMMIT
protected void closeSession(Session session)
Can be overridden in subclasses, e.g. for flushing the Session before closing it. See class-level javadoc for a discussion of flush handling. Note that you should also override getSession accordingly, to set the flush mode to something else than NEVER.
session
- the Session used for filtering
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |