Search in sources :

Example 1 with SqlRepositoryBeanConfig

use of com.evolveum.midpoint.repo.sql.SqlRepositoryBeanConfig in project midpoint by Evolveum.

the class TestSqlRepositoryBeanConfig method sessionFactory.

/*
     * This is working alternative to @Autowired private LocalSessionFactoryBean sessionFactory
     * with @PostConstruct init method that adds the properties. That solution didn't work, because
     * the properties are probably used to initialize the session before added.
     * This nicely reuses existing production config method and adds the properties before they
     * are read and reflected in the final setup.
     * (There is actually just one test that using the inspector - ObjectDeltaUpdaterTest.)
     */
@Bean
@Primary
public LocalSessionFactoryBean sessionFactory(DataSource dataSource, SqlRepositoryConfiguration configuration, MidPointImplicitNamingStrategy midPointImplicitNamingStrategy, MidPointPhysicalNamingStrategy midPointPhysicalNamingStrategy, EntityStateInterceptor entityStateInterceptor) {
    LocalSessionFactoryBean sessionFactory = new SqlRepositoryBeanConfig().sessionFactory(dataSource, configuration, midPointImplicitNamingStrategy, midPointPhysicalNamingStrategy, entityStateInterceptor);
    // These are only test-related changes regarding the session factory.
    Properties hibernateProperties = sessionFactory.getHibernateProperties();
    hibernateProperties.setProperty("hibernate.show_sql", "false");
    hibernateProperties.setProperty("hibernate.session_factory.statement_inspector", "com.evolveum.midpoint.repo.sql.testing.TestStatementInspector");
    return sessionFactory;
}
Also used : SqlRepositoryBeanConfig(com.evolveum.midpoint.repo.sql.SqlRepositoryBeanConfig) LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) Properties(java.util.Properties) LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean)

Aggregations

SqlRepositoryBeanConfig (com.evolveum.midpoint.repo.sql.SqlRepositoryBeanConfig)1 Properties (java.util.Properties)1 LocalSessionFactoryBean (org.springframework.orm.hibernate5.LocalSessionFactoryBean)1