Class AnnotationSessionFactoryBean
- java.lang.Object
- org.springframework.orm.hibernate3.HibernateExceptionTranslator
- org.springframework.orm.hibernate3.AbstractSessionFactoryBean
- org.springframework.orm.hibernate3.LocalSessionFactoryBean
- org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,DisposableBean
,FactoryBean<SessionFactory>
,InitializingBean
,ResourceLoaderAware
,PersistenceExceptionTranslator
@Deprecated public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implements ResourceLoaderAware
Deprecated.as of Spring 4.3, in favor of Hibernate 4.x/5.xSubclass of Spring's standard LocalSessionFactoryBean for Hibernate, supporting annotation metadata for mappings.Example for an AnnotationSessionFactoryBean bean definition:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="annotatedClasses"> <list> <value>test.package.Foo</value> <value>test.package.Bar</value> </list> </property> </bean>
Or when using classpath scanning for autodetection of entity classes:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="packagesToScan" value="test.package"/> </bean>
Requires Hibernate 3.6.x, as of Spring 4.0.
Field Summary
Fields inherited from class org.springframework.orm.hibernate3.AbstractSessionFactoryBean
logger
Constructor Summary
Constructors Constructor Description AnnotationSessionFactoryBean()
Deprecated.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
postProcessMappings(Configuration config)
Deprecated.Reads metadata from annotated classes and packages into the AnnotationConfiguration instance.protected void
scanPackages(Configuration config)
Deprecated.Perform Spring-based scanning for entity classes.void
setAnnotatedClasses(Class<?>... annotatedClasses)
Deprecated.Specify annotated classes, for which mappings will be read from class-level annotation metadata.void
setAnnotatedPackages(String... annotatedPackages)
Deprecated.Specify the names of annotated packages, for which package-level annotation metadata will be read.void
setEntityTypeFilters(TypeFilter... entityTypeFilters)
Deprecated.Specify custom type filters for Spring-based scanning for entity classes.void
setPackagesToScan(String... packagesToScan)
Deprecated.Specify packages to search using Spring-based scanning for entity classes in the classpath.void
setResourceLoader(ResourceLoader resourceLoader)
Deprecated.Set the ResourceLoader that this object runs in.Methods inherited from class org.springframework.orm.hibernate3.LocalSessionFactoryBean
afterSessionFactoryCreation, buildSessionFactory, createDatabaseSchema, destroy, dropDatabaseSchema, executeSchemaScript, executeSchemaStatement, getConfigTimeDataSource, getConfigTimeLobHandler, getConfigTimeTransactionManager, getConfiguration, getHibernateProperties, newConfiguration, newSessionFactory, postProcessConfiguration, setBeanClassLoader, setCacheableMappingLocations, setCacheRegionFactory, setCollectionCacheStrategies, setConfigLocation, setConfigLocations, setConfigurationClass, setEntityCacheStrategies, setEntityInterceptor, setEventListeners, setFilterDefinitions, setHibernateProperties, setJtaTransactionManager, setLobHandler, setMappingDirectoryLocations, setMappingJarLocations, setMappingLocations, setMappingResources, setNamingStrategy, setSchemaUpdate, setTypeDefinitions, updateDatabaseSchema, validateDatabaseSchema
Methods inherited from class org.springframework.orm.hibernate3.AbstractSessionFactoryBean
afterPropertiesSet, beforeSessionFactoryDestruction, getDataSource, getObject, getObjectType, getSessionFactory, isExposeTransactionAwareSessionFactory, isSingleton, isUseTransactionAwareDataSource, setDataSource, setExposeTransactionAwareSessionFactory, setUseTransactionAwareDataSource, wrapSessionFactoryIfNecessary
Methods inherited from class org.springframework.orm.hibernate3.HibernateExceptionTranslator
convertHibernateAccessException, setJdbcExceptionTranslator, translateExceptionIfPossible
Constructor Detail
AnnotationSessionFactoryBean
public AnnotationSessionFactoryBean()
Deprecated.
Method Detail
setAnnotatedClasses
public void setAnnotatedClasses(Class<?>... annotatedClasses)
Deprecated.Specify annotated classes, for which mappings will be read from class-level annotation metadata.
setAnnotatedPackages
public void setAnnotatedPackages(String... annotatedPackages)
Deprecated.Specify the names of annotated packages, for which package-level annotation metadata will be read.- See Also:
Configuration.addPackage(String)
setPackagesToScan
public void setPackagesToScan(String... packagesToScan)
Deprecated.Specify packages to search using Spring-based scanning for entity classes in the classpath. This is an alternative to listing annotated classes explicitly.Default is none. Specify packages to search for autodetection of your entity classes in the classpath. This is analogous to Spring's component-scan feature (
ClassPathBeanDefinitionScanner
).
setEntityTypeFilters
public void setEntityTypeFilters(TypeFilter... entityTypeFilters)
Deprecated.Specify custom type filters for Spring-based scanning for entity classes.Default is to search all specified packages for classes annotated with
@javax.persistence.Entity
,@javax.persistence.Embeddable
or@javax.persistence.MappedSuperclass
, as well as for Hibernate's special@org.hibernate.annotations.Entity
.
setResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)
Deprecated.Description copied from interface:ResourceLoaderAware
Set the ResourceLoader that this object runs in.This might be a ResourcePatternResolver, which can be checked through
instanceof ResourcePatternResolver
. See also theResourcePatternUtils.getResourcePatternResolver
method.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSet
or a custom init-method. Invoked before ApplicationContextAware'ssetApplicationContext
.- Specified by:
setResourceLoader
in interfaceResourceLoaderAware
- Parameters:
resourceLoader
- the ResourceLoader object to be used by this object- See Also:
ResourcePatternResolver
,ResourcePatternUtils.getResourcePatternResolver(org.springframework.core.io.ResourceLoader)
postProcessMappings
protected void postProcessMappings(Configuration config) throws HibernateException
Deprecated.Reads metadata from annotated classes and packages into the AnnotationConfiguration instance.- Overrides:
postProcessMappings
in classLocalSessionFactoryBean
- Parameters:
config
- the current Configuration object- Throws:
HibernateException
- in case of Hibernate initialization errors- See Also:
Configuration.buildMappings()
scanPackages
protected void scanPackages(Configuration config)
Deprecated.Perform Spring-based scanning for entity classes.