|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.orm.toplink.SessionFactoryUtils
public abstract class SessionFactoryUtils
Helper class featuring methods for TopLink Session handling, allowing for reuse of TopLink Session instances within transactions. Also provides support for exception translation.
Mainly intended for internal use within the framework.
Constructor Summary | |
---|---|
SessionFactoryUtils()
|
Method Summary | |
---|---|
static DataAccessException |
convertTopLinkAccessException(oracle.toplink.exceptions.TopLinkException ex)
Convert the given TopLinkException to an appropriate exception from the org.springframework.dao hierarchy. |
static oracle.toplink.sessions.Session |
doGetSession(SessionFactory sessionFactory,
boolean allowCreate)
Get a TopLink Session for the given SessionFactory. |
static oracle.toplink.sessions.Session |
getSession(SessionFactory sessionFactory,
boolean allowCreate)
Get a TopLink Session for the given SessionFactory. |
static boolean |
isSessionTransactional(oracle.toplink.sessions.Session session,
SessionFactory sessionFactory)
Return whether the given TopLink Session is transactional, that is, bound to the current thread by Spring's transaction facilities. |
static void |
releaseSession(oracle.toplink.sessions.Session session,
SessionFactory sessionFactory)
Close the given Session, created via the given factory, if it is not managed externally (i.e. not bound to the thread). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SessionFactoryUtils()
Method Detail |
---|
public static oracle.toplink.sessions.Session getSession(SessionFactory sessionFactory, boolean allowCreate) throws DataAccessResourceFailureException, IllegalStateException
true
.
This is the getSession
method used by typical data access code,
in combination with releaseSession
called when done with
the Session. Note that TopLinkTemplate allows to write data access code
without caring about such resource handling.
sessionFactory
- TopLink SessionFactory to create the session withallowCreate
- if a non-transactional Session should be created when no
transactional Session can be found for the current thread
DataAccessResourceFailureException
- if the Session couldn't be created
IllegalStateException
- if no thread-bound Session found and
"allowCreate" is false
releaseSession(oracle.toplink.sessions.Session, org.springframework.orm.toplink.SessionFactory)
,
TopLinkTemplate
public static oracle.toplink.sessions.Session doGetSession(SessionFactory sessionFactory, boolean allowCreate) throws oracle.toplink.exceptions.TopLinkException, IllegalStateException
true
.
Same as getSession
, but throwing the original TopLinkException.
sessionFactory
- TopLink SessionFactory to create the session withallowCreate
- if a non-transactional Session should be created when no
transactional Session can be found for the current thread
oracle.toplink.exceptions.TopLinkException
- if the Session couldn't be created
IllegalStateException
- if no thread-bound Session found and
"allowCreate" is false
releaseSession(oracle.toplink.sessions.Session, org.springframework.orm.toplink.SessionFactory)
,
TopLinkTemplate
public static boolean isSessionTransactional(oracle.toplink.sessions.Session session, SessionFactory sessionFactory)
session
- the TopLink Session to checksessionFactory
- TopLink SessionFactory that the Session was created with
(can be null
)
public static DataAccessException convertTopLinkAccessException(oracle.toplink.exceptions.TopLinkException ex)
org.springframework.dao
hierarchy.
ex
- TopLinkException that occured
public static void releaseSession(oracle.toplink.sessions.Session session, SessionFactory sessionFactory)
session
- the TopLink Session to closesessionFactory
- TopLink SessionFactory that the Session was created with
(can be null
)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |