类 HibernateExceptionTranslator
- java.lang.Object
- org.springframework.orm.hibernate3.HibernateExceptionTranslator
- 所有已实现的接口:
PersistenceExceptionTranslator
- 直接已知子类:
AbstractSessionFactoryBean
@Deprecated public class HibernateExceptionTranslator extends Object implements PersistenceExceptionTranslator
已过时。as of Spring 4.3, in favor of Hibernate 4.x/5.xPersistenceExceptionTranslator
capable of translatingHibernateException
instances to Spring'sDataAccessException
hierarchy.Extended by
LocalSessionFactoryBean
, so there is no need to declare this translator in addition to aLocalSessionFactoryBean
.When configuring the container with
@Configuration
classes, a@Bean
of this type must be registered manually.- 从以下版本开始:
- 3.1
- 作者:
- Juergen Hoeller, Chris Beams
- 另请参阅:
PersistenceExceptionTranslationPostProcessor
,SessionFactoryUtils.convertHibernateAccessException(HibernateException)
,SQLExceptionTranslator
构造器概要
构造器 构造器 说明 HibernateExceptionTranslator()
已过时。
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 protected DataAccessException
convertHibernateAccessException(HibernateException ex)
已过时。Convert the given HibernateException to an appropriate exception from theorg.springframework.dao
hierarchy.void
setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
已过时。Set the JDBC exception translator for the SessionFactory, exposed via the PersistenceExceptionTranslator interface.DataAccessException
translateExceptionIfPossible(RuntimeException ex)
已过时。Translate the given runtime exception thrown by a persistence framework to a corresponding exception from Spring's genericDataAccessException
hierarchy, if possible.
构造器详细资料
HibernateExceptionTranslator
public HibernateExceptionTranslator()
已过时。
方法详细资料
setJdbcExceptionTranslator
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
已过时。Set the JDBC exception translator for the SessionFactory, exposed via the PersistenceExceptionTranslator interface.Applied to any SQLException root cause of a Hibernate JDBCException, overriding Hibernate's default SQLException translation (which is based on Hibernate's Dialect for a specific target database).
- 参数:
jdbcExceptionTranslator
- the exception translator- 另请参阅:
SQLException
,JDBCException
,SQLErrorCodeSQLExceptionTranslator
,SQLStateSQLExceptionTranslator
,PersistenceExceptionTranslator
translateExceptionIfPossible
public DataAccessException translateExceptionIfPossible(RuntimeException ex)
已过时。从接口复制的说明:PersistenceExceptionTranslator
Translate the given runtime exception thrown by a persistence framework to a corresponding exception from Spring's genericDataAccessException
hierarchy, if possible.Do not translate exceptions that are not understood by this translator: for example, if coming from another persistence framework, or resulting from user code or otherwise unrelated to persistence.
Of particular importance is the correct translation to DataIntegrityViolationException, for example on constraint violation. Implementations may use Spring JDBC's sophisticated exception translation to provide further information in the event of SQLException as a root cause.
- 指定者:
translateExceptionIfPossible
在接口中PersistenceExceptionTranslator
- 参数:
ex
- a RuntimeException to translate- 返回:
- the corresponding DataAccessException (or
null
if the exception could not be translated, as in this case it may result from user code rather than from an actual persistence problem) - 另请参阅:
DataIntegrityViolationException
,SQLExceptionTranslator
convertHibernateAccessException
protected DataAccessException convertHibernateAccessException(HibernateException ex)
已过时。Convert the given HibernateException to an appropriate exception from theorg.springframework.dao
hierarchy.Will automatically apply a specified SQLExceptionTranslator to a Hibernate JDBCException, else rely on Hibernate's default translation.
- 参数:
ex
- HibernateException that occured- 返回:
- a corresponding DataAccessException
- 另请参阅:
SessionFactoryUtils.convertHibernateAccessException(org.hibernate.HibernateException)
,setJdbcExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)