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 like 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
           
 
Constructor Summary
TopLinkAccessor()
           
 
Method Summary
 void afterPropertiesSet()
          Check that we were provided with a session to use
protected  DataAccessException convertJdbcAccessException(SQLException ex)
          Convert the given SQLException to an appropriate exception from the org.springframework.dao hierarchy.
 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.
 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
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 TopLink DatabaseExceptions thrown by callback code.

The default exception translator is a SQLStateSQLExceptionTranslator.

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

getJdbcExceptionTranslator

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

Creates a default SQLStateSQLExceptionTranslator, if no exception translator explicitly specified.


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 detect wrapped SQLExceptions and convert them accordingly.

The default implementation delegates to TopLinkUtils and convertJdbcAccessException. Can be overridden in subclasses.

Parameters:
ex - TopLinkException that occured
Returns:
the corresponding DataAccessException instance
See Also:
convertJdbcAccessException(java.sql.SQLException), SessionFactoryUtils.convertTopLinkAccessException(oracle.toplink.exceptions.TopLinkException)

convertJdbcAccessException

protected DataAccessException convertJdbcAccessException(SQLException ex)
Convert the given SQLException to an appropriate exception from the org.springframework.dao hierarchy. Can be overridden in subclasses.

Parameters:
ex - SQLException that occured
Returns:
the corresponding DataAccessException instance
See Also:
setJdbcExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)


Copyright (c) 2002-2007 The Spring Framework Project.