Package org.beangle.orm.hibernate
Class SessionFactoryBean
- java.lang.Object
-
- org.beangle.orm.hibernate.SessionFactoryBean
-
- All Implemented Interfaces:
Disposable,Initializing,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>
public class SessionFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>, Initializing, Disposable, org.springframework.beans.factory.BeanClassLoaderAware
- Version:
- $Id: SessionFactoryBean.java Feb 27, 2012 10:52:27 PM chaostone $
- Author:
- chaostone
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description SessionFactoryBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()org.hibernate.cfg.ConfigurationgetConfiguration()DataSourcegetDataSource()PropertiesgetHibernateProperties()Return the Hibernate properties, if any.org.hibernate.SessionFactorygetObject()Class<? extends org.hibernate.SessionFactory>getObjectType()org.hibernate.SessionFactorygetSessionFactory()voidinit()booleanisSingleton()protected org.hibernate.cfg.ConfigurationnewConfiguration()Subclasses can override this method to perform custom initialization of the Configuration instance used for SessionFactory creation.protected voidprocessProperties()voidsetBeanClassLoader(ClassLoader classLoader)voidsetConfigLocations(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".voidsetConfigurationClass(Class<? extends org.hibernate.cfg.Configuration> configurationClass)voidsetDataSource(DataSource dataSource)voidsetHibernateProperties(Properties hibernateProperties)Set Hibernate properties, such as "hibernate.dialect".voidsetNamingStrategy(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.voidsetPersistLocations(org.springframework.core.io.Resource[] persistLocations)voidsetStaticHbm(org.springframework.core.io.Resource staticHbm)
-
-
-
Method Detail
-
setConfigLocations
public 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".Note: Can be omitted when all necessary properties and mapping resources are specified locally via this bean.
- See Also:
Configuration.configure(java.net.URL)
-
setPersistLocations
public void setPersistLocations(org.springframework.core.io.Resource[] persistLocations)
-
setHibernateProperties
public void setHibernateProperties(Properties hibernateProperties)
Set Hibernate properties, such as "hibernate.dialect".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.
- See Also:
setDataSource(javax.sql.DataSource)
-
getHibernateProperties
public Properties getHibernateProperties()
Return the Hibernate properties, if any. Mainly available for configuration through property paths that specify individual keys.
-
setNamingStrategy
public 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.- See Also:
Configuration.setNamingStrategy(org.hibernate.cfg.NamingStrategy)
-
processProperties
protected void processProperties()
-
init
public void init() throws Exception- Specified by:
initin interfaceInitializing- Throws:
Exception
-
newConfiguration
protected org.hibernate.cfg.Configuration newConfiguration() throws org.hibernate.HibernateExceptionSubclasses can override this method to perform custom initialization of the Configuration instance used for SessionFactory creation. The properties of this LocalSessionFactoryBean will be applied to the Configuration object that gets returned here.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.
- Returns:
- the Configuration instance
- Throws:
org.hibernate.HibernateException- in case of Hibernate initialization errors- See Also:
Configuration()
-
destroy
public void destroy() throws org.hibernate.HibernateException- Specified by:
destroyin interfaceDisposable- Throws:
org.hibernate.HibernateException
-
setBeanClassLoader
public void setBeanClassLoader(ClassLoader classLoader)
- Specified by:
setBeanClassLoaderin interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
getObject
public org.hibernate.SessionFactory getObject()
- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>
-
getObjectType
public Class<? extends org.hibernate.SessionFactory> getObjectType()
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>
-
isSingleton
public boolean isSingleton()
- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>
-
getDataSource
public DataSource getDataSource()
-
setDataSource
public void setDataSource(DataSource dataSource)
-
getSessionFactory
public org.hibernate.SessionFactory getSessionFactory()
-
setConfigurationClass
public void setConfigurationClass(Class<? extends org.hibernate.cfg.Configuration> configurationClass)
-
getConfiguration
public org.hibernate.cfg.Configuration getConfiguration()
-
setStaticHbm
public void setStaticHbm(org.springframework.core.io.Resource staticHbm)
-
-