Configuration class,
adding SpringSessionContext as a default and providing convenient ways
to specify a JDBC DataSource and an application class loader.
This is designed for programmatic use, e.g. in @Bean factory methods;
consider using LocalSessionFactoryBean for XML bean definition files.
Typically combined with HibernateTransactionManager for declarative
transactions against the SessionFactory and its JDBC DataSource.
Compatible with Hibernate ORM 5.5/5.6, as of Spring Framework 6.0.
This Hibernate-specific factory builder can also be a convenient way to set up
a JPA EntityManagerFactory since the Hibernate SessionFactory
natively exposes the JPA EntityManagerFactory interface as well now.
This builder supports Hibernate BeanContainer integration,
MetadataSources from custom BootstrapServiceRegistryBuilder
setup, as well as other advanced Hibernate configuration options beyond the
standard JPA bootstrap contract.
HibernateTransactionManager, LocalSessionFactoryBean, setBeanContainer, LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources), BootstrapServiceRegistryBuilder
| Modifier and Type | Class and Description |
|---|---|
| private class | LocalSessionFactoryBuilder.
Proxy invocation handler for background bootstrapping, only enforcing
a fully initialized target |
| Modifier and Type | Field and Description |
|---|---|
| private static final TypeFilter | |
| private static final TypeFilter[] | |
| private TypeFilter[] | |
| private static final String | |
| private static final String | |
| private static final String | |
| private final ResourcePatternResolver | |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| public | LocalSessionFactoryBuilder(DataSource
the JDBC DataSource that the resulting Hibernate SessionFactory should be using
(may be dataSource)null)Create a new LocalSessionFactoryBuilder for the given DataSource. |
| public | LocalSessionFactoryBuilder(DataSource
the JDBC DataSource that the resulting Hibernate SessionFactory should be using
(may be dataSource, ClassLoader null)the ClassLoader to load application classes from classLoader)Create a new LocalSessionFactoryBuilder for the given DataSource. |
| public | LocalSessionFactoryBuilder(DataSource
the JDBC DataSource that the resulting Hibernate SessionFactory should be using
(may be dataSource, ResourceLoader null)the ResourceLoader to load application classes from resourceLoader)Create a new LocalSessionFactoryBuilder for the given DataSource. |
| public | LocalSessionFactoryBuilder(DataSource
the JDBC DataSource that the resulting Hibernate SessionFactory should be using
(may be dataSource, ResourceLoader null)the ResourceLoader to load application classes from resourceLoader, MetadataSources the Hibernate MetadataSources service to use (e.g. reusing an existing one) metadataSources)Create a new LocalSessionFactoryBuilder for the given DataSource. |
| Modifier and Type | Method and Description |
|---|---|
| public LocalSessionFactoryBuilder | |
| public LocalSessionFactoryBuilder | |
| public SessionFactory | buildSessionFactory(AsyncTaskExecutor bootstrapExecutor)
References Deprecated
SessionFactory is deprecated or references (maybe indirectly) at least one deprecated element.
Build the Hibernate |
| private boolean | matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory)
Check whether any of the configured entity type filters matches the current class descriptor contained in the metadata reader. |
| public LocalSessionFactoryBuilder | scanPackages(String...
one or more Java package names packagesToScan)Perform Spring-based scanning for entity classes, registering them
as annotated classes with this |
| public LocalSessionFactoryBuilder | setBeanContainer(ConfigurableListableBeanFactory beanFactory)
Set a Hibernate |
| public LocalSessionFactoryBuilder | setCacheRegionFactory(RegionFactory cacheRegionFactory)
Set the Hibernate |
| public void | setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver currentTenantIdentifierResolver)
Overrides org. Overridden to reliably pass a |
| public LocalSessionFactoryBuilder | setEntityTypeFilters(TypeFilter... entityTypeFilters)
Specify custom type filters for Spring-based scanning for entity classes. |
| public LocalSessionFactoryBuilder | setJtaTransactionManager(Object jtaTransactionManager)
Set the Spring |
| public LocalSessionFactoryBuilder | setMultiTenantConnectionProvider(MultiTenantConnectionProvider multiTenantConnectionProvider)
Set a |
| CONVERTER_TYPE_FILTER | back to summary |
|---|---|
| private static final TypeFilter CONVERTER_TYPE_FILTER | |
| DEFAULT_ENTITY_TYPE_FILTERS | back to summary |
|---|---|
| private static final TypeFilter[] DEFAULT_ENTITY_TYPE_FILTERS | |
| entityTypeFilters | back to summary |
|---|---|
| private TypeFilter[] entityTypeFilters
| |
| IGNORE_CLASSFORMAT_PROPERTY_NAME | back to summary |
|---|---|
| private static final String IGNORE_CLASSFORMAT_PROPERTY_NAME | |
| PACKAGE_INFO_SUFFIX | back to summary |
|---|---|
| private static final String PACKAGE_INFO_SUFFIX | |
| RESOURCE_PATTERN | back to summary |
|---|---|
| private static final String RESOURCE_PATTERN | |
| resourcePatternResolver | back to summary |
|---|---|
| private final ResourcePatternResolver resourcePatternResolver | |
| shouldIgnoreClassFormatException | back to summary |
|---|---|
| private static final boolean shouldIgnoreClassFormatException | |
| LocalSessionFactoryBuilder | back to summary |
|---|---|
| public LocalSessionFactoryBuilder(DataSource dataSource) Create a new LocalSessionFactoryBuilder for the given DataSource.
| |
| LocalSessionFactoryBuilder | back to summary |
|---|---|
| public LocalSessionFactoryBuilder(DataSource dataSource, ClassLoader classLoader) Create a new LocalSessionFactoryBuilder for the given DataSource.
| |
| LocalSessionFactoryBuilder | back to summary |
|---|---|
| public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) Create a new LocalSessionFactoryBuilder for the given DataSource.
| |
| LocalSessionFactoryBuilder | back to summary |
|---|---|
| public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader, MetadataSources metadataSources) Create a new LocalSessionFactoryBuilder for the given DataSource.
| |
| addAnnotatedClasses | back to summary |
|---|---|
| public LocalSessionFactoryBuilder addAnnotatedClasses(Class<?>... annotatedClasses) Add the given annotated classes in a batch.
| |
| addPackages | back to summary |
|---|---|
| public LocalSessionFactoryBuilder addPackages(String... annotatedPackages) Add the given annotated packages in a batch.
| |
| buildSessionFactory | back to summary |
|---|---|
| public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor)
References Deprecated
See corresponding docs for further information. Build the Hibernate
| |
| matchesEntityTypeFilter | back to summary |
|---|---|
| private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException Check whether any of the configured entity type filters matches the current class descriptor contained in the metadata reader. | |
| scanPackages | back to summary |
|---|---|
| public LocalSessionFactoryBuilder scanPackages(String... packagesToScan) throws HibernateException Perform Spring-based scanning for entity classes, registering them
as annotated classes with this
| |
| setBeanContainer | back to summary |
|---|---|
| public LocalSessionFactoryBuilder setBeanContainer(ConfigurableListableBeanFactory beanFactory) Set a Hibernate This enables autowiring of Hibernate attribute converters and entity listeners.
| |
| setCacheRegionFactory | back to summary |
|---|---|
| public LocalSessionFactoryBuilder setCacheRegionFactory(RegionFactory cacheRegionFactory) Set the Hibernate Note If this is set, the Hibernate settings should not define a cache provider to avoid meaningless double configuration.
| |
| setCurrentTenantIdentifierResolver | back to summary |
|---|---|
| public void setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver currentTenantIdentifierResolver) Overrides org. Overridden to reliably pass a
| |
| setEntityTypeFilters | back to summary |
|---|---|
| public LocalSessionFactoryBuilder setEntityTypeFilters(TypeFilter... entityTypeFilters) Specify custom type filters for Spring-based scanning for entity classes. Default is to search all specified packages for classes annotated with
| |
| setJtaTransactionManager | back to summary |
|---|---|
| public LocalSessionFactoryBuilder setJtaTransactionManager(Object jtaTransactionManager) Set the Spring A passed-in Spring Note If this is set, the Hibernate settings should not contain a JTA platform setting to avoid meaningless double configuration. | |
| setMultiTenantConnectionProvider | back to summary |
|---|---|
| public LocalSessionFactoryBuilder setMultiTenantConnectionProvider(MultiTenantConnectionProvider multiTenantConnectionProvider) Set a
| |
SessionFactory when actually needed.
| Modifier and Type | Field and Description |
|---|---|
| private final Future |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private SessionFactory | getSessionFactory()
References Deprecated
SessionFactory is deprecated or references (maybe indirectly) at least one deprecated element.
|
| public Object | invoke(Object
the proxy instance that the method was invoked on proxy, Method the method, Object[] Method instance corresponding to
the interface method invoked on the proxy instance. The declaring
class of the Method object will be the interface that
the method was declared in, which may be a superinterface of the
proxy interface that the proxy class inherits the method through.an array of objects containing the values of the
arguments passed in the method invocation on the proxy instance,
or args)null if interface method takes no arguments.
Arguments of primitive types are wrapped in instances of the
appropriate primitive wrapper class, such as
java.lang.Integer or java.lang.Boolean.Implements java. Processes a method invocation on a proxy instance and returns the result. |
| sessionFactoryFuture | back to summary |
|---|---|
| private final Future<SessionFactory> sessionFactoryFuture | |
| BootstrapSessionFactoryInvocationHandler | back to summary |
|---|---|
| public BootstrapSessionFactoryInvocationHandler(AsyncTaskExecutor bootstrapExecutor) | |
| getSessionFactory | back to summary |
|---|---|
| private SessionFactory getSessionFactory()
References Deprecated
See corresponding docs for further information. | |
| invoke | back to summary |
|---|---|
| public Object invoke(Object proxy, Method method, Object[] args) throws Throwable Implements java. Doc from java. Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.
| |