org.springframework.orm.toplink
Class TopLinkAccessor

java.lang.Object
  extended by org.springframework.orm.toplink.TopLinkAccessor
All Implemented Interfaces:
InitializingBean
Direct Known Subclasses:
TopLinkInterceptor, TopLinkTemplate

public abstract class TopLinkAccessor
extends Object
implements InitializingBean

Base class for TopLinkTemplate and TopLinkInterceptor, defining common properties such as SessionFactory and JDBC exception translator.

Not intended to be used directly. See TopLinkTemplate and TopLinkInterceptor.

Thanks to Slavik Markovich for implementing the initial TopLink support prototype!

Since:
1.2
Author:
Juergen Hoeller
See Also:
TopLinkTemplate, TopLinkInterceptor

Field Summary
protected  Log logger
          Logger available to subclasses
 
Constructor Summary
TopLinkAccessor()
           
 
Method Summary
 void afterPropertiesSet()
          Check that we were provided with a session to use
 DataAccessException convertTopLinkAccessException(oracle.toplink.exceptions.TopLinkException ex)
          Convert the given TopLinkException to an appropriate exception from the org.springframework.dao hierarchy.
 SQLExceptionTranslator getJdbcExceptionTranslator()
          Return the JDBC exception translator for this instance, if any.
 SessionFactory getSessionFactory()
          Return the TopLink SessionFactory that should be used to create TopLink Sessions.
 void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
          Set the JDBC exception translator for this instance.
 void setSessionFactory(SessionFactory sessionFactory)
          Set the the TopLink SessionFactory that should be used to create TopLink Sessions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses

Constructor Detail

TopLinkAccessor

public TopLinkAccessor()
Method Detail

setSessionFactory

public void setSessionFactory(SessionFactory sessionFactory)
Set the the TopLink SessionFactory that should be used to create TopLink Sessions. This will usually be a ServerSessionFactory in a multi-threaded environment, but can also be a SingleSessionFactory for testing purposes or for standalone execution.

The passed-in SessionFactory will usually be asked for a plain Session to perform data access on, unless an active transaction with a thread-bound Session is found.

See Also:
ServerSessionFactory, SingleSessionFactory, SessionFactory.createSession(), SessionFactoryUtils.getSession(SessionFactory, boolean)

getSessionFactory

public SessionFactory getSessionFactory()
Return the TopLink SessionFactory that should be used to create TopLink Sessions.


setJdbcExceptionTranslator

public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
Set the JDBC exception translator for this instance.

Applied to any SQLException root cause of a TopLink DatabaseException. The default is to rely on TopLink's native exception translation.

Parameters:
jdbcExceptionTranslator - the exception translator
See Also:
DatabaseException, SQLErrorCodeSQLExceptionTranslator, SQLStateSQLExceptionTranslator

getJdbcExceptionTranslator

public SQLExceptionTranslator getJdbcExceptionTranslator()
Return the JDBC exception translator for this instance, if any.


afterPropertiesSet

public void afterPropertiesSet()
Check that we were provided with a session to use

Specified by:
afterPropertiesSet in interface InitializingBean

convertTopLinkAccessException

public DataAccessException convertTopLinkAccessException(oracle.toplink.exceptions.TopLinkException ex)
Convert the given TopLinkException to an appropriate exception from the org.springframework.dao hierarchy.

Will automatically apply a specified SQLExceptionTranslator to a TopLink DatabaseException, else rely on TopLink's default translation.

Parameters:
ex - TopLinkException that occured
Returns:
a corresponding DataAccessException
See Also:
SessionFactoryUtils.convertTopLinkAccessException(oracle.toplink.exceptions.TopLinkException), setJdbcExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)


Copyright © 2002-2008 The Spring Framework.