public class ConfigurableLocalSessionFactoryBean
extends org.springframework.orm.hibernate4.HibernateExceptionTranslator
implements org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>, org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanClassLoaderAware
| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.context.ApplicationContext |
applicationContext |
protected java.lang.ClassLoader |
classLoader |
protected java.lang.Class<?> |
configClass |
protected java.lang.Class<?> |
currentSessionContextClass |
protected java.lang.String |
dataSourceName |
protected java.util.Map<java.lang.String,java.lang.Object> |
eventListeners |
protected org.codehaus.groovy.grails.commons.GrailsApplication |
grailsApplication |
protected org.codehaus.groovy.grails.orm.hibernate.HibernateEventListeners |
hibernateEventListeners |
protected boolean |
proxyIfReloadEnabled |
protected java.lang.String |
sessionFactoryBeanName |
| Constructor and Description |
|---|
ConfigurableLocalSessionFactoryBean() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected void |
buildSessionFactory() |
protected void |
buildSessionFactoryProxy() |
protected void |
configureGrailsJdbcTransactionFactory(org.hibernate.cfg.Configuration config) |
void |
destroy() |
protected org.hibernate.SessionFactory |
doBuildSessionFactory() |
java.lang.Class<?>[] |
getAnnotatedClasses() |
java.lang.String[] |
getAnnotatedPackages() |
org.springframework.core.io.Resource[] |
getCacheableMappingLocations() |
protected java.lang.String |
getCauseMessage(org.hibernate.HibernateException e) |
java.lang.Class<?> |
getConfigClass() |
org.springframework.core.io.Resource[] |
getConfigLocations() |
org.hibernate.cfg.Configuration |
getConfiguration()
Return the Hibernate Configuration object used to build the SessionFactory.
|
java.lang.Class<?> |
getCurrentSessionContextClass() |
javax.sql.DataSource |
getDataSource() |
java.lang.String |
getDataSourceName() |
org.hibernate.Interceptor |
getEntityInterceptor() |
java.util.Map<java.lang.String,java.lang.Object> |
getEventListeners() |
org.codehaus.groovy.grails.commons.GrailsApplication |
getGrailsApplication() |
org.codehaus.groovy.grails.orm.hibernate.HibernateEventListeners |
getHibernateEventListeners() |
java.util.Properties |
getHibernateProperties()
Return the Hibernate properties, if any.
|
org.springframework.core.io.Resource[] |
getMappingDirectoryLocations() |
org.springframework.core.io.Resource[] |
getMappingJarLocations() |
org.springframework.core.io.Resource[] |
getMappingLocations() |
java.lang.String[] |
getMappingResources() |
org.hibernate.cfg.NamingStrategy |
getNamingStrategy() |
org.hibernate.SessionFactory |
getObject() |
java.lang.Class<?> |
getObjectType() |
java.lang.String[] |
getPackagesToScan() |
java.lang.String |
getSessionFactoryBeanName() |
protected boolean |
isCacheConfigurationError(java.lang.Throwable cause) |
boolean |
isProxyIfReloadEnabled() |
boolean |
isSingleton() |
protected GrailsAnnotationConfiguration |
newConfiguration() |
void |
setAnnotatedClasses(java.lang.Class<?>[] annotatedClasses)
Specify annotated entity classes to register with this Hibernate SessionFactory.
|
void |
setAnnotatedPackages(java.lang.String[] annotatedPackages)
Specify the names of annotated packages, for which package-level
annotation metadata will be read.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setBeanClassLoader(java.lang.ClassLoader beanClassLoader) |
void |
setCacheableMappingLocations(org.springframework.core.io.Resource[] cacheableMappingLocations)
Set locations of cacheable Hibernate mapping files, for example as web app
resource "/WEB-INF/mapping/example.hbm.xml".
|
void |
setConfigClass(java.lang.Class<?> configClass)
Sets the class to be used for Hibernate Configuration.
|
void |
setConfigLocation(org.springframework.core.io.Resource configLocation)
Set the location of a single Hibernate XML config file, for example as
classpath resource "classpath:hibernate.cfg.xml".
|
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 |
setCurrentSessionContextClass(java.lang.Class<?> currentSessionContextClass)
Sets class to be used for the Hibernate CurrentSessionContext.
|
void |
setDataSource(javax.sql.DataSource dataSource)
Set the DataSource to be used by the SessionFactory.
|
void |
setDataSourceName(java.lang.String name) |
void |
setEntityInterceptor(org.hibernate.Interceptor entityInterceptor)
Set a Hibernate entity interceptor that allows to inspect and change
property values before writing to and reading from the database.
|
void |
setEventListeners(java.util.Map<java.lang.String,java.lang.Object> eventListeners)
Specify the Hibernate event listeners to register, with listener types
as keys and listener objects as values.
|
void |
setGrailsApplication(org.codehaus.groovy.grails.commons.GrailsApplication grailsApplication) |
void |
setHibernateEventListeners(org.codehaus.groovy.grails.orm.hibernate.HibernateEventListeners listeners) |
void |
setHibernateProperties(java.util.Properties hibernateProperties)
Set Hibernate properties, such as "hibernate.dialect".
|
void |
setMappingDirectoryLocations(org.springframework.core.io.Resource[] mappingDirectoryLocations)
Set locations of directories that contain Hibernate mapping resources,
like "WEB-INF/mappings".
|
void |
setMappingJarLocations(org.springframework.core.io.Resource[] mappingJarLocations)
Set locations of jar files that contain Hibernate mapping resources,
like "WEB-INF/lib/example.hbm.jar".
|
void |
setMappingLocations(org.springframework.core.io.Resource[] mappingLocations)
Set locations of Hibernate mapping files, for example as classpath
resource "classpath:example.hbm.xml".
|
void |
setMappingResources(java.lang.String[] mappingResources)
Set Hibernate mapping resources to be found in the class path,
like "example.hbm.xml" or "mypackage/example.hbm.xml".
|
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 |
setPackagesToScan(java.lang.String... packagesToScan)
Specify packages to search for autodetection of your entity classes in the
classpath.
|
void |
setProxyIfReloadEnabled(boolean proxyIfReloadEnabled) |
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) |
void |
setSessionFactoryBeanName(java.lang.String name) |
protected org.codehaus.groovy.grails.commons.GrailsApplication grailsApplication
protected java.lang.ClassLoader classLoader
protected java.lang.Class<?> configClass
protected java.lang.Class<?> currentSessionContextClass
protected java.util.Map<java.lang.String,java.lang.Object> eventListeners
protected org.codehaus.groovy.grails.orm.hibernate.HibernateEventListeners hibernateEventListeners
protected org.springframework.context.ApplicationContext applicationContext
protected boolean proxyIfReloadEnabled
protected java.lang.String sessionFactoryBeanName
protected java.lang.String dataSourceName
public void setDataSource(javax.sql.DataSource dataSource)
If this is set, the Hibernate settings should not define a connection provider to avoid meaningless double configuration.
public javax.sql.DataSource getDataSource()
public void setConfigLocation(org.springframework.core.io.Resource configLocation)
Note: Can be omitted when all necessary properties and mapping resources are specified locally via this bean.
Configuration.configure(java.net.URL)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 org.springframework.core.io.Resource[] getConfigLocations()
public void setMappingResources(java.lang.String[] mappingResources)
Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
setMappingLocations(org.springframework.core.io.Resource[]),
Configuration.addResource(java.lang.String, java.lang.ClassLoader)public java.lang.String[] getMappingResources()
public void setMappingLocations(org.springframework.core.io.Resource[] mappingLocations)
Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
Configuration.addInputStream(java.io.InputStream)public org.springframework.core.io.Resource[] getMappingLocations()
public void setCacheableMappingLocations(org.springframework.core.io.Resource[] cacheableMappingLocations)
Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
Configuration.addCacheableFile(java.io.File)public org.springframework.core.io.Resource[] getCacheableMappingLocations()
public void setMappingJarLocations(org.springframework.core.io.Resource[] mappingJarLocations)
Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
Configuration.addJar(java.io.File)public org.springframework.core.io.Resource[] getMappingJarLocations()
public void setMappingDirectoryLocations(org.springframework.core.io.Resource[] mappingDirectoryLocations)
Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
Configuration.addDirectory(java.io.File)public org.springframework.core.io.Resource[] getMappingDirectoryLocations()
public void setEntityInterceptor(org.hibernate.Interceptor entityInterceptor)
Configuration.setInterceptor(org.hibernate.Interceptor)public org.hibernate.Interceptor getEntityInterceptor()
public void setNamingStrategy(org.hibernate.cfg.NamingStrategy namingStrategy)
Configuration.setNamingStrategy(org.hibernate.cfg.NamingStrategy)public org.hibernate.cfg.NamingStrategy getNamingStrategy()
public void setHibernateProperties(java.util.Properties hibernateProperties)
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 java.util.Properties getHibernateProperties()
public void setAnnotatedClasses(java.lang.Class<?>[] annotatedClasses)
Configuration.addAnnotatedClass(Class)public java.lang.Class<?>[] getAnnotatedClasses()
public void setAnnotatedPackages(java.lang.String[] annotatedPackages)
Configuration.addPackage(String)public java.lang.String[] getAnnotatedPackages()
public void setPackagesToScan(java.lang.String... packagesToScan)
org.springframework.context.annotation.ClassPathBeanDefinitionScanner).public java.lang.String[] getPackagesToScan()
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
setResourceLoader in interface org.springframework.context.ResourceLoaderAwarepublic void setProxyIfReloadEnabled(boolean proxyIfReloadEnabled)
proxyIfReloadEnabled - Sets whether a proxy should be created if reload is enabledpublic boolean isProxyIfReloadEnabled()
public void setCurrentSessionContextClass(java.lang.Class<?> currentSessionContextClass)
currentSessionContextClass - An implementation of the CurrentSessionContext interfacepublic java.lang.Class<?> getCurrentSessionContextClass()
public void setConfigClass(java.lang.Class<?> configClass)
configClass - A subclass of the Hibernate Configuration classpublic java.lang.Class<?> getConfigClass()
public void setGrailsApplication(org.codehaus.groovy.grails.commons.GrailsApplication grailsApplication)
grailsApplication - The grailsApplication to set.public org.codehaus.groovy.grails.commons.GrailsApplication getGrailsApplication()
public void setHibernateEventListeners(org.codehaus.groovy.grails.orm.hibernate.HibernateEventListeners listeners)
public org.codehaus.groovy.grails.orm.hibernate.HibernateEventListeners getHibernateEventListeners()
public void setSessionFactoryBeanName(java.lang.String name)
public java.lang.String getSessionFactoryBeanName()
public void setDataSourceName(java.lang.String name)
public java.lang.String getDataSourceName()
public void setEventListeners(java.util.Map<java.lang.String,java.lang.Object> eventListeners)
See the Hibernate documentation for further details on listener types and associated listener interfaces.
eventListeners - Map with listener type Strings as keys and
listener objects as valuespublic java.util.Map<java.lang.String,java.lang.Object> getEventListeners()
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionprotected void buildSessionFactory()
throws java.lang.Exception
java.lang.Exceptionprotected org.hibernate.SessionFactory doBuildSessionFactory()
protected void buildSessionFactoryProxy()
public final org.hibernate.cfg.Configuration getConfiguration()
java.lang.IllegalStateException - if the Configuration object has not been initialized yetpublic org.hibernate.SessionFactory getObject()
getObject in interface org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>public java.lang.Class<?> 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 void destroy()
destroy in interface org.springframework.beans.factory.DisposableBeanprotected GrailsAnnotationConfiguration newConfiguration() throws java.lang.Exception
java.lang.Exceptionprotected void configureGrailsJdbcTransactionFactory(org.hibernate.cfg.Configuration config)
public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAwareprotected java.lang.String getCauseMessage(org.hibernate.HibernateException e)
protected boolean isCacheConfigurationError(java.lang.Throwable cause)
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansException