use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cas by apereo.
the class Beans method newHibernateEntityManagerFactoryBean.
/**
* New entity manager factory bean.
*
* @param config the config
* @param jpaProperties the jpa properties
* @return the local container entity manager factory bean
*/
public static LocalContainerEntityManagerFactoryBean newHibernateEntityManagerFactoryBean(final JpaConfigDataHolder config, final AbstractJpaProperties jpaProperties) {
final LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setJpaVendorAdapter(config.getJpaVendorAdapter());
if (StringUtils.isNotBlank(config.getPersistenceUnitName())) {
bean.setPersistenceUnitName(config.getPersistenceUnitName());
}
bean.setPackagesToScan(config.getPackagesToScan());
bean.setDataSource(config.getDataSource());
final Properties properties = new Properties();
properties.put("hibernate.dialect", jpaProperties.getDialect());
properties.put("hibernate.hbm2ddl.auto", jpaProperties.getDdlAuto());
properties.put("hibernate.jdbc.batch_size", jpaProperties.getBatchSize());
if (StringUtils.isNotBlank(jpaProperties.getDefaultCatalog())) {
properties.put("hibernate.default_catalog", jpaProperties.getDefaultCatalog());
}
if (StringUtils.isNotBlank(jpaProperties.getDefaultSchema())) {
properties.put("hibernate.default_schema", jpaProperties.getDefaultSchema());
}
bean.setJpaProperties(properties);
return bean;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cas by apereo.
the class GoogleAuthenticatorJpaConfiguration method googleAuthenticatorEntityManagerFactory.
@Lazy
@Bean
public LocalContainerEntityManagerFactoryBean googleAuthenticatorEntityManagerFactory() {
final LocalContainerEntityManagerFactoryBean bean = Beans.newHibernateEntityManagerFactoryBean(new JpaConfigDataHolder(jpaGoogleAuthenticatorVendorAdapter(), "jpaGoogleAuthenticatorContext", jpaPackagesToScanGoogleAuthenticator(), dataSourceGoogleAuthenticator()), casProperties.getAuthn().getMfa().getGauth().getJpa().getDatabase());
bean.getJpaPropertyMap().put("hibernate.enable_lazy_load_no_trans", Boolean.TRUE);
return bean;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project spring-security by spring-projects.
the class DataConfiguration method entityManagerFactory.
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setDatabase(Database.HSQL);
vendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan(Message.class.getPackage().getName());
factory.setDataSource(dataSource());
return factory;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cas by apereo.
the class JdbcMultifactorAuthnTrustConfiguration method mfaTrustedAuthnEntityManagerFactory.
@Lazy
@Bean
public LocalContainerEntityManagerFactoryBean mfaTrustedAuthnEntityManagerFactory() {
final LocalContainerEntityManagerFactoryBean bean = Beans.newHibernateEntityManagerFactoryBean(new JpaConfigDataHolder(jpaMfaTrustedAuthnVendorAdapter(), "jpaMfaTrustedAuthnContext", jpaMfaTrustedAuthnPackagesToScan(), dataSourceMfaTrustedAuthn()), casProperties.getAuthn().getMfa().getTrusted().getJpa());
bean.getJpaPropertyMap().put("hibernate.enable_lazy_load_no_trans", Boolean.TRUE);
return bean;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cas by apereo.
the class SamlIdPJpaMetadataConfiguration method samlMetadataEntityManagerFactory.
@Lazy
@Bean
public LocalContainerEntityManagerFactoryBean samlMetadataEntityManagerFactory() {
final SamlIdPMetadataProperties idp = casProperties.getAuthn().getSamlIdp().getMetadata();
final LocalContainerEntityManagerFactoryBean bean = JpaBeans.newHibernateEntityManagerFactoryBean(new JpaConfigDataHolder(jpaSamlMetadataVendorAdapter(), "jpaSamlMetadataContext", jpaSamlMetadataPackagesToScan(), dataSourceSamlMetadata()), idp.getJpa());
return bean;
}
Aggregations