|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.orm.hibernate3.SessionFactoryBuilderSupport<SessionFactoryBuilder>
org.springframework.orm.hibernate3.SessionFactoryBuilder
org.springframework.orm.hibernate3.LocalSessionFactoryBean
public class LocalSessionFactoryBean
Subclass of SessionFactoryBuilder adhering to Spring's
FactoryBean contract,
making it suitable for use in XML configuration.
A typical LocalSessionFactoryBean bean definition:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingLocations" value="classpath:com/foo/*.hbm.xml"/>
</bean>
Implements the
PersistenceExceptionTranslator interface, as autodetected by Spring's PersistenceExceptionTranslationPostProcessor, for AOP-based translation of
native Hibernate exceptions to Spring's DataAccessException hierarchy.
Hence, the presence of an LocalSessionFactoryBean automatically
enables a PersistenceExceptionTranslationPostProcessor to translate
Hibernate exceptions.
SessionFactoryBuilderSupport,
SessionFactoryBeanOperations,
AnnotationSessionFactoryBean| Field Summary |
|---|
| Fields inherited from class org.springframework.orm.hibernate3.SessionFactoryBuilderSupport |
|---|
logger |
| Constructor Summary | |
|---|---|
LocalSessionFactoryBean()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Build and expose the SessionFactory. |
void |
destroy()
Close the SessionFactory on bean factory shutdown. |
org.hibernate.SessionFactory |
getObject()
Return the singleton SessionFactory. |
Class<? extends org.hibernate.SessionFactory> |
getObjectType()
Return the SessionFactory class used. |
boolean |
isSingleton()
Return true. |
protected org.hibernate.SessionFactory |
newSessionFactory(org.hibernate.cfg.Configuration config)
Deprecated. as of Spring 3.1 in favor of SessionFactoryBuilderSupport.newSessionFactory() which
can access the internal Configuration instance via SessionFactoryBuilderSupport.getConfiguration(). |
protected void |
postBuildSessionFactory()
Allow cleaning up resources, thread locals, etc after building the SessionFactory. |
protected void |
postProcessConfiguration(org.hibernate.cfg.Configuration config)
Deprecated. as of Spring 3.1 in favor of SessionFactoryBuilderSupport.postProcessConfiguration() which
can access the internal Configuration instance via SessionFactoryBuilderSupport.getConfiguration(). |
protected void |
postProcessMappings(org.hibernate.cfg.Configuration config)
Deprecated. as of Spring 3.1 in favor of SessionFactoryBuilderSupport.postProcessMappings() which
can access the internal Configuration instance via SessionFactoryBuilderSupport.getConfiguration(). |
protected void |
preBuildSessionFactory()
Allow additional population of the underlying Configuration
instance. |
void |
setBeanClassLoader(ClassLoader classLoader)
Exists for compatibility with BeanClassLoaderAware but
simply delegates to
setClassLoader. |
void |
setCacheProvider(org.hibernate.cache.CacheProvider cacheProvider)
Deprecated. |
void |
setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
Set the JDBC exception translator for the SessionFactory on this instance's underlying HibernateExceptionTranslator. |
void |
setPersistenceExceptionTranslator(HibernateExceptionTranslator hibernateExceptionTranslator)
Customize the HibernateExceptionTranslator to be used when translating native
HibernateException types to Spring's DataAccessException hierarchy. |
DataAccessException |
translateExceptionIfPossible(RuntimeException ex)
Implementation of the PersistenceExceptionTranslator interface, as autodetected by Spring's PersistenceExceptionTranslationPostProcessor. |
org.hibernate.SessionFactory |
wrapSessionFactoryIfNecessary(org.hibernate.SessionFactory rawSf)
Wrap the given SessionFactory with a proxy, if demanded. |
| Methods inherited from class org.springframework.orm.hibernate3.SessionFactoryBuilder |
|---|
getDefaultConfigurationClass |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LocalSessionFactoryBean()
| Method Detail |
|---|
@Deprecated public void setCacheProvider(org.hibernate.cache.CacheProvider cacheProvider)
SessionFactoryBeanOperationssetCacheRegionFactory
following Hibernate 3.3's deprecation of the CacheProvider SPI.
Set the Hibernate CacheProvider to use for the SessionFactory.
Allows for using a Spring-managed CacheProvider instance.
Note: If this is set, the Hibernate settings should not define a
cache provider to avoid meaningless double configuration.
of the CacheProvider SPI in favor of RegionFactory SPI.
setCacheProvider in interface SessionFactoryBeanOperationsprotected final void preBuildSessionFactory()
SessionFactoryBuilderSupportConfiguration
instance. Called during SessionFactoryBuilderSupport.doBuildSessionFactory().
preBuildSessionFactory in class SessionFactoryBuilderSupport<SessionFactoryBuilder>protected final void postBuildSessionFactory()
SessionFactoryBuilderSupportSessionFactory. Called during the finally block of
SessionFactoryBuilderSupport.doBuildSessionFactory().
postBuildSessionFactory in class SessionFactoryBuilderSupport<SessionFactoryBuilder>
public void destroy()
throws org.hibernate.HibernateException
SessionFactoryBeanOperations
destroy in interface DisposableBeandestroy in interface SessionFactoryBeanOperationsorg.hibernate.HibernateException
public org.hibernate.SessionFactory getObject()
throws Exception
SessionFactoryBeanOperations
getObject in interface FactoryBean<org.hibernate.SessionFactory>getObject in interface SessionFactoryBeanOperationsnull)
Exception - in case of creation errorsFactoryBeanNotInitializedExceptionpublic Class<? extends org.hibernate.SessionFactory> getObjectType()
SessionFactoryBeanOperations
getObjectType in interface FactoryBean<org.hibernate.SessionFactory>getObjectType in interface SessionFactoryBeanOperationsnull if not known at the time of the callListableBeanFactory.getBeansOfType(java.lang.Class) public void setBeanClassLoader(ClassLoader classLoader)
SessionFactoryBeanOperationsBeanClassLoaderAware but
simply delegates to
setClassLoader.
setBeanClassLoader in interface BeanClassLoaderAwaresetBeanClassLoader in interface SessionFactoryBeanOperationsclassLoader - the owning class loader; may be null in
which case a default ClassLoader must be used, for example
the ClassLoader obtained via
ClassUtils.getDefaultClassLoader()public boolean isSingleton()
SessionFactoryBeanOperationstrue.
isSingleton in interface FactoryBean<org.hibernate.SessionFactory>isSingleton in interface SessionFactoryBeanOperationsFactoryBean.getObject(),
SmartFactoryBean.isPrototype()
public void afterPropertiesSet()
throws Exception
SessionFactoryBeanOperations
afterPropertiesSet in interface InitializingBeanafterPropertiesSet in interface SessionFactoryBeanOperationsException - in the event of misconfiguration (such
as failure to set an essential property) or if initialization fails.SessionFactoryBuilderSupport.buildSessionFactory(),
SessionFactoryBuilderSupport.doBuildSessionFactory(),
SessionFactoryBuilderSupport.wrapSessionFactoryIfNecessary(org.hibernate.SessionFactory),
SessionFactoryBuilderSupport.afterSessionFactoryCreation()public DataAccessException translateExceptionIfPossible(RuntimeException ex)
SessionFactoryBeanOperationsConverts the exception if it is a HibernateException;
else returns null to indicate an unknown exception.
translateExceptionIfPossible in interface PersistenceExceptionTranslatortranslateExceptionIfPossible in interface SessionFactoryBeanOperationsex - a RuntimeException thrown
null if the
exception could not be translated, as in this case it may result from
user code rather than an actual persistence problem)PersistenceExceptionTranslationPostProcessor,
#convertHibernateAccessExceptionpublic void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
SessionFactoryBeanOperationsHibernateExceptionTranslator.
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).
setJdbcExceptionTranslator in interface SessionFactoryBeanOperationsjdbcExceptionTranslator - the exception translatorSessionFactoryBeanOperations.setPersistenceExceptionTranslator(HibernateExceptionTranslator),
HibernateExceptionTranslator.setJdbcExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator),
SQLException,
JDBCException,
SQLErrorCodeSQLExceptionTranslator,
SQLStateSQLExceptionTranslator,
PersistenceExceptionTranslatorpublic void setPersistenceExceptionTranslator(HibernateExceptionTranslator hibernateExceptionTranslator)
SessionFactoryBeanOperationsHibernateExceptionTranslator to be used when translating native
HibernateException types to Spring's DataAccessException hierarchy.
setPersistenceExceptionTranslator in interface SessionFactoryBeanOperationspublic org.hibernate.SessionFactory wrapSessionFactoryIfNecessary(org.hibernate.SessionFactory rawSf)
SessionFactoryBuilderSupportSessionFactory with a proxy, if demanded.
The default implementation wraps the given SessionFactory as a Spring
DisposableBean proxy in order to call SessionFactory.close() on
ApplicationContext shutdown.
Subclasses may override this to implement transaction awareness through
a SessionFactory proxy for example, or even to avoid creation of the
DisposableBean proxy altogether.
wrapSessionFactoryIfNecessary in interface SessionFactoryBeanOperationswrapSessionFactoryIfNecessary in class SessionFactoryBuilderSupport<SessionFactoryBuilder>rawSf - the raw SessionFactory as built by SessionFactoryBuilderSupport.buildSessionFactory()
SessionFactory reference to exposeSessionFactoryBuilderSupport.buildSessionFactory()
@Deprecated
protected org.hibernate.SessionFactory newSessionFactory(org.hibernate.cfg.Configuration config)
throws org.hibernate.HibernateException
SessionFactoryBuilderSupport.newSessionFactory() which
can access the internal Configuration instance via SessionFactoryBuilderSupport.getConfiguration().
org.hibernate.HibernateException
@Deprecated
protected void postProcessMappings(org.hibernate.cfg.Configuration config)
throws org.hibernate.HibernateException
SessionFactoryBuilderSupport.postProcessMappings() which
can access the internal Configuration instance via SessionFactoryBuilderSupport.getConfiguration().
org.hibernate.HibernateException
@Deprecated
protected void postProcessConfiguration(org.hibernate.cfg.Configuration config)
throws org.hibernate.HibernateException
SessionFactoryBuilderSupport.postProcessConfiguration() which
can access the internal Configuration instance via SessionFactoryBuilderSupport.getConfiguration().
org.hibernate.HibernateException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||