Skip to content

Commit

Permalink
remove sessionFactory bean in HibernateConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
vietnguyen committed Nov 15, 2023
1 parent 7ca34ed commit 4fbe455
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
Expand Down Expand Up @@ -108,13 +107,6 @@ public DefaultHibernateCacheManager cacheManager(
return cacheManager;
}

@Bean("sessionFactory")
@Primary
public SessionFactory sessionFactory(
@Qualifier("entityManagerFactory") EntityManagerFactory entityManager) {
return entityManager.unwrap(SessionFactory.class);
}

@Bean
public DbmsManager dbmsManager(
JdbcTemplate jdbcTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.hisp.dhis.system.startup.StartupListener;
import org.hisp.dhis.webapi.security.config.WebMvcConfig;
import org.springframework.core.annotation.Order;
import org.springframework.orm.hibernate5.support.OpenSessionInViewFilter;
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter;
import org.springframework.security.web.session.HttpSessionEventPublisher;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
Expand Down Expand Up @@ -104,8 +104,9 @@ public static void setupServlets(
.addMappingForUrlPatterns(null, false, "/api/*");

FilterRegistration.Dynamic openSessionInViewFilter =
context.addFilter("openSessionInViewFilter", OpenSessionInViewFilter.class);
openSessionInViewFilter.setInitParameter("sessionFactoryBeanName", "sessionFactory");
context.addFilter("openSessionInViewFilter", OpenEntityManagerInViewFilter.class);
openSessionInViewFilter.setInitParameter(
"entityManagerFactoryBeanName", "entityManagerFactory");
openSessionInViewFilter.addMappingForUrlPatterns(null, false, "/*");
openSessionInViewFilter.addMappingForServletNames(null, false, "dispatcher");

Expand Down

0 comments on commit 4fbe455

Please sign in to comment.