java.lang.Objectorg.springframework.orm.hibernate3.AbstractSessionFactoryBean
All Implemented Interfaces:
PersistenceExceptionTranslator, DisposableBean, InitializingBean, FactoryBean
Direct Known Subclasses:
LocalSessionFactoryBean, AnnotationSessionFactoryBean
This class implements the org.springframework.dao.support.PersistenceExceptionTranslator interface, as autodetected by Spring's org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor , for AOP-based translation of native exceptions to Spring DataAccessExceptions. Hence, the presence of e.g. LocalSessionFactoryBean automatically enables a PersistenceExceptionTranslationPostProcessor to translate Hibernate exceptions.
This class mainly serves as common base class for LocalSessionFactoryBean . For details on typical SessionFactory setup, see the LocalSessionFactoryBean javadoc.
Juergen - Hoeller2.0 - | Field Summary | ||
|---|---|---|
| protected final Log | logger | Logger available to subclasses |
| Method from org.springframework.orm.hibernate3.AbstractSessionFactoryBean Summary: |
|---|
| afterPropertiesSet, afterSessionFactoryCreation, beforeSessionFactoryDestruction, buildSessionFactory, convertHibernateAccessException, destroy, getDataSource, getObject, getObjectType, getSessionFactory, isExposeTransactionAwareSessionFactory, isSingleton, isUseTransactionAwareDataSource, setDataSource, setExposeTransactionAwareSessionFactory, setJdbcExceptionTranslator, setUseTransactionAwareDataSource, translateExceptionIfPossible, wrapSessionFactoryIfNecessary |
| Methods from java.lang.Object: |
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.springframework.orm.hibernate3.AbstractSessionFactoryBean Detail: |
|---|
|
getSessionFactory() at this point.
This implementation is empty. |
getSessionFactory() at this point.
This implementation is empty. |
|
org.springframework.dao hierarchy.
Will automatically apply a specified SQLExceptionTranslator to a Hibernate JDBCException, else rely on Hibernate's default translation. |
|
|
|
|
|
|
|
|
If this is set, the Hibernate settings should not define a connection provider to avoid meaningless double configuration. If using HibernateTransactionManager as transaction strategy, consider proxying your target DataSource with a LazyConnectionDataSourceProxy. This defers fetching of an actual JDBC Connection until the first JDBC Statement gets executed, even within JDBC transactions (as performed by HibernateTransactionManager). Such lazy fetching is particularly beneficial for read-only operations, in particular if the chances of resolving the result in the second-level cache are high. As JTA and transactional JNDI DataSources already provide lazy enlistment of JDBC Connections, LazyConnectionDataSourceProxy does not add value with JTA (i.e. Spring's JtaTransactionManager) as transaction strategy. |
getCurrentSession() method, returning the
Session that's associated with the current Spring-managed transaction, if any.
Default is "true", letting data access code work with the plain
Hibernate SessionFactory and its Turn this flag off to expose the plain Hibernate SessionFactory with
Hibernate's default |
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). |
Default is "false": LocalSessionFactoryBean is usually used with Spring's HibernateTransactionManager or JtaTransactionManager, both of which work nicely on a plain JDBC DataSource. Hibernate Sessions and their JDBC Connections are fully managed by the Hibernate/JTA transaction infrastructure in such a scenario. If you switch this flag to "true", Spring's Hibernate access will be able to participate in JDBC-based transactions managed outside of Hibernate (for example, by Spring's DataSourceTransactionManager). This can be convenient if you need a different local transaction strategy for another O/R mapping tool, for example, but still want Hibernate access to join into those transactions. A further benefit of this option is that plain Sessions opened directly
via the SessionFactory, outside of Spring's Hibernate support, will still
participate in active Spring-managed transactions. However, consider using
Hibernate's WARNING: When using a transaction-aware JDBC DataSource in combination with OpenSessionInViewFilter/Interceptor, whether participating in JTA or external JDBC-based transactions, it is strongly recommended to set Hibernate's Connection release mode to "after_transaction" or "after_statement", which guarantees proper Connection handling in such a scenario. In contrast to that, HibernateTransactionManager generally requires release mode "on_close". Note: If you want to use Hibernate's Connection release mode "after_statement" with a DataSource specified on this LocalSessionFactoryBean (for example, a JTA-aware DataSource fetched from JNDI), switch this setting to "true". Otherwise, the ConnectionProvider used underneath will vote against aggressive release and thus silently switch to release mode "after_transaction". |
Converts the exception if it is a HibernateException;
else returns |
The default implementation simply returns the given SessionFactory as-is. Subclasses may override this to implement transaction awareness through a SessionFactory proxy, for example. |