public class SessionFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>, Initializing, Disposable, org.springframework.beans.factory.BeanClassLoaderAware
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SessionFactoryBean() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
org.hibernate.cfg.Configuration |
getConfiguration() |
DataSource |
getDataSource() |
Properties |
getHibernateProperties()
Return the Hibernate properties, if any.
|
org.hibernate.SessionFactory |
getObject() |
Class<? extends org.hibernate.SessionFactory> |
getObjectType() |
org.hibernate.SessionFactory |
getSessionFactory() |
void |
init() |
boolean |
isSingleton() |
protected org.hibernate.cfg.Configuration |
newConfiguration()
Subclasses can override this method to perform custom initialization
of the Configuration instance used for SessionFactory creation.
|
protected void |
processProperties() |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setConfigLocations(org.springframework.core.io.Resource[] configLocations)
Set the locations of multiple Hibernate XML config files, for example as
classpath resources "classpath:hibernate.cfg.xml,classpath:extension.cfg.xml".
|
void |
setConfigurationClass(Class<? extends org.hibernate.cfg.Configuration> configurationClass) |
void |
setDataSource(DataSource dataSource) |
void |
setHibernateProperties(Properties hibernateProperties)
Set Hibernate properties, such as "hibernate.dialect".
|
void |
setNamingStrategy(org.hibernate.cfg.NamingStrategy namingStrategy)
Set a Hibernate NamingStrategy for the SessionFactory, determining the
physical column and table names given the info in the mapping document.
|
void |
setPersistLocations(org.springframework.core.io.Resource[] persistLocations) |
void |
setStaticHbm(org.springframework.core.io.Resource staticHbm) |
public void setConfigLocations(org.springframework.core.io.Resource[] configLocations)
Note: Can be omitted when all necessary properties and mapping resources are specified locally via this bean.
Configuration.configure(java.net.URL)public void setPersistLocations(org.springframework.core.io.Resource[] persistLocations)
public void setHibernateProperties(Properties hibernateProperties)
Can be used to override values in a Hibernate XML config file, or to specify all necessary properties locally.
Note: Do not specify a transaction provider here when using Spring-driven transactions. It is also advisable to omit connection provider settings and use a Spring-set DataSource instead.
setDataSource(javax.sql.DataSource)public Properties getHibernateProperties()
public void setNamingStrategy(org.hibernate.cfg.NamingStrategy namingStrategy)
Configuration.setNamingStrategy(org.hibernate.cfg.NamingStrategy)protected void processProperties()
public void init()
throws Exception
init in interface InitializingExceptionprotected org.hibernate.cfg.Configuration newConfiguration()
throws org.hibernate.HibernateException
The default implementation creates a new Configuration instance. A custom implementation could prepare the instance in a specific way, or use a custom Configuration subclass.
org.hibernate.HibernateException - in case of Hibernate initialization errorsConfiguration.Configuration()public void destroy()
throws org.hibernate.HibernateException
destroy in interface Disposableorg.hibernate.HibernateExceptionpublic void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAwarepublic org.hibernate.SessionFactory getObject()
getObject in interface org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>public Class<? extends org.hibernate.SessionFactory> getObjectType()
getObjectType in interface org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>public boolean isSingleton()
isSingleton in interface org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>public DataSource getDataSource()
public void setDataSource(DataSource dataSource)
public org.hibernate.SessionFactory getSessionFactory()
public void setConfigurationClass(Class<? extends org.hibernate.cfg.Configuration> configurationClass)
public org.hibernate.cfg.Configuration getConfiguration()
public void setStaticHbm(org.springframework.core.io.Resource staticHbm)
Copyright © 2005–2016 The Beangle Software Group. All rights reserved.