| java.lang.Object org.springframework.orm.toplink.SessionFactoryUtils
SessionFactoryUtils | abstract public class SessionFactoryUtils (Code) | | 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.
author: Juergen Hoeller author: James Clark since: 1.2 |
Method Summary | |
public static DataAccessException | convertTopLinkAccessException(TopLinkException ex) Convert the given TopLinkException to an appropriate exception from the
org.springframework.dao hierarchy. | public static Session | doGetSession(SessionFactory sessionFactory, boolean allowCreate) Get a TopLink Session for the given SessionFactory. | public static Session | getSession(SessionFactory sessionFactory, boolean allowCreate) Get a TopLink Session for the given SessionFactory. | public static boolean | isSessionTransactional(Session session, SessionFactory sessionFactory) Return whether the given TopLink Session is transactional, that is,
bound to the current thread by Spring's transaction facilities. | public static void | releaseSession(Session session, SessionFactory sessionFactory) Close the given Session, created via the given factory,
if it is not managed externally (i.e. |
convertTopLinkAccessException | public static DataAccessException convertTopLinkAccessException(TopLinkException ex)(Code) | | Convert the given TopLinkException to an appropriate exception from the
org.springframework.dao hierarchy.
Parameters: ex - TopLinkException that occured the corresponding DataAccessException instance |
doGetSession | public static Session doGetSession(SessionFactory sessionFactory, boolean allowCreate) throws TopLinkException, IllegalStateException(Code) | | Get a TopLink Session for the given SessionFactory. Is aware of and will
return any existing corresponding Session bound to the current thread, for
example when using TopLinkTransactionManager. Will create a new Session
otherwise, if "allowCreate" is true .
Same as getSession , but throwing the original TopLinkException.
Parameters: sessionFactory - TopLink SessionFactory to create the session with Parameters: allowCreate - if a non-transactional Session should be created when notransactional Session can be found for the current thread the TopLink Session throws: TopLinkException - if the Session couldn't be created throws: IllegalStateException - if no thread-bound Session found and"allowCreate" is false See Also: SessionFactoryUtils.releaseSession See Also: TopLinkTemplate |
getSession | public static Session getSession(SessionFactory sessionFactory, boolean allowCreate) throws DataAccessResourceFailureException, IllegalStateException(Code) | | Get a TopLink Session for the given SessionFactory. Is aware of and will
return any existing corresponding Session bound to the current thread, for
example when using TopLinkTransactionManager. Will create a new Session
otherwise, if "allowCreate" is 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.
Parameters: sessionFactory - TopLink SessionFactory to create the session with Parameters: allowCreate - if a non-transactional Session should be created when notransactional Session can be found for the current thread the TopLink Session throws: DataAccessResourceFailureException - if the Session couldn't be created throws: IllegalStateException - if no thread-bound Session found and"allowCreate" is false See Also: SessionFactoryUtils.releaseSession See Also: TopLinkTemplate |
isSessionTransactional | public static boolean isSessionTransactional(Session session, SessionFactory sessionFactory)(Code) | | Return whether the given TopLink Session is transactional, that is,
bound to the current thread by Spring's transaction facilities.
Parameters: session - the TopLink Session to check Parameters: sessionFactory - TopLink SessionFactory that the Session was created with(can be null ) whether the Session is transactional |
releaseSession | public static void releaseSession(Session session, SessionFactory sessionFactory)(Code) | | Close the given Session, created via the given factory,
if it is not managed externally (i.e. not bound to the thread).
Parameters: session - the TopLink Session to close Parameters: sessionFactory - TopLink SessionFactory that the Session was created with(can be null ) |
|
|