|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -51,21 +51,20 @@ import org.springframework.core.io.support.ResourcePatternUtils; |
|
|
|
import org.springframework.core.task.AsyncTaskExecutor; |
|
|
|
import org.springframework.core.task.AsyncTaskExecutor; |
|
|
|
import org.springframework.core.type.filter.TypeFilter; |
|
|
|
import org.springframework.core.type.filter.TypeFilter; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@link FactoryBean} that creates a Hibernate {@link SessionFactory}. This is the usual |
|
|
|
* {@link FactoryBean} that creates a Hibernate {@link SessionFactory}. This is the usual |
|
|
|
* way to set up a shared Hibernate SessionFactory in a Spring application context; the |
|
|
|
* way to set up a shared Hibernate SessionFactory in a Spring application context; the |
|
|
|
* SessionFactory can then be passed to data access objects via dependency injection. |
|
|
|
* SessionFactory can then be passed to data access objects via dependency injection. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Compatible with Hibernate 5.2/5.3/5.4, as of Spring 5.3. |
|
|
|
* <p>Compatible with Hibernate 5.5/5.6, as of Spring 6.0. |
|
|
|
* This Hibernate-specific {@code LocalSessionFactoryBean} can be an immediate alternative |
|
|
|
* This Hibernate-specific {@code LocalSessionFactoryBean} can be an immediate alternative |
|
|
|
* to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for common |
|
|
|
* to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for |
|
|
|
* JPA purposes: In particular with Hibernate 5.3/5.4, the Hibernate {@code SessionFactory} |
|
|
|
* common JPA purposes: The Hibernate {@code SessionFactory} will natively expose the JPA |
|
|
|
* will natively expose the JPA {@code EntityManagerFactory} interface as well, and |
|
|
|
* {@code EntityManagerFactory} interface as well, and Hibernate {@code BeanContainer} |
|
|
|
* Hibernate {@code BeanContainer} integration will be registered out of the box. |
|
|
|
* integration will be registered out of the box. In combination with |
|
|
|
* In combination with {@link HibernateTransactionManager}, this naturally allows for |
|
|
|
* {@link HibernateTransactionManager}, this naturally allows for mixing JPA access code |
|
|
|
* mixing JPA access code with native Hibernate access code within the same transaction. |
|
|
|
* with native Hibernate access code within the same transaction. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @since 4.2 |
|
|
|
* @since 4.2 |
|
|
|
@ -469,17 +468,14 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Accept the containing {@link BeanFactory}, registering corresponding Hibernate |
|
|
|
* Accept the containing {@link BeanFactory}, registering corresponding Hibernate |
|
|
|
* {@link org.hibernate.resource.beans.container.spi.BeanContainer} integration for |
|
|
|
* {@link org.hibernate.resource.beans.container.spi.BeanContainer} integration for |
|
|
|
* it if possible. This requires a Spring {@link ConfigurableListableBeanFactory} |
|
|
|
* it if possible. This requires a Spring {@link ConfigurableListableBeanFactory}. |
|
|
|
* and Hibernate 5.3 or higher on the classpath. |
|
|
|
|
|
|
|
* @since 5.1 |
|
|
|
* @since 5.1 |
|
|
|
* @see SpringBeanContainer |
|
|
|
* @see SpringBeanContainer |
|
|
|
* @see LocalSessionFactoryBuilder#setBeanContainer |
|
|
|
* @see LocalSessionFactoryBuilder#setBeanContainer |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setBeanFactory(BeanFactory beanFactory) { |
|
|
|
public void setBeanFactory(BeanFactory beanFactory) { |
|
|
|
if (beanFactory instanceof ConfigurableListableBeanFactory && |
|
|
|
if (beanFactory instanceof ConfigurableListableBeanFactory) { |
|
|
|
ClassUtils.isPresent("org.hibernate.resource.beans.container.spi.BeanContainer", |
|
|
|
|
|
|
|
getClass().getClassLoader())) { |
|
|
|
|
|
|
|
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; |
|
|
|
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|