|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.orm.hibernate4.HibernateExceptionTranslator
org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean
public class ConfigurableLocalSessionFactoryBean
A SessionFactory bean that allows the configuration class to be changed and customise for usage within Grails.
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
ConfigurableLocalSessionFactoryBean()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
protected void |
buildSessionFactory()
|
protected void |
buildSessionFactoryProxy()
|
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)
|
| Methods inherited from class org.springframework.orm.hibernate4.HibernateExceptionTranslator |
|---|
convertHibernateAccessException, translateExceptionIfPossible |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
public ConfigurableLocalSessionFactoryBean()
| Method Detail |
|---|
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)
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.Exception
protected 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.DisposableBean
protected GrailsAnnotationConfiguration newConfiguration()
throws java.lang.Exception
java.lang.Exceptionpublic 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||