Search in sources :

Example 1 with LocalContainerEntityManagerFactoryBean

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;
}
Also used : PasswordEncoderProperties(org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties) AbstractLdapAuthenticationProperties(org.apereo.cas.configuration.model.support.ldap.AbstractLdapAuthenticationProperties) PrincipalAttributesProperties(org.apereo.cas.configuration.model.core.authentication.PrincipalAttributesProperties) DatabaseProperties(org.apereo.cas.configuration.model.support.jpa.DatabaseProperties) Properties(java.util.Properties) ConnectionPoolingProperties(org.apereo.cas.configuration.model.support.ConnectionPoolingProperties) AbstractMongoInstanceProperties(org.apereo.cas.configuration.model.support.mongo.AbstractMongoInstanceProperties) CryptographyProperties(org.apereo.cas.configuration.model.core.util.CryptographyProperties) AbstractJpaProperties(org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties) AbstractLdapProperties(org.apereo.cas.configuration.model.support.ldap.AbstractLdapProperties) PrincipalTransformationProperties(org.apereo.cas.configuration.model.core.authentication.PrincipalTransformationProperties) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 2 with LocalContainerEntityManagerFactoryBean

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;
}
Also used : JpaConfigDataHolder(org.apereo.cas.configuration.model.support.jpa.JpaConfigDataHolder) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Lazy(org.springframework.context.annotation.Lazy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 3 with LocalContainerEntityManagerFactoryBean

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;
}
Also used : HibernateJpaVendorAdapter(org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 4 with LocalContainerEntityManagerFactoryBean

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;
}
Also used : JpaConfigDataHolder(org.apereo.cas.configuration.model.support.jpa.JpaConfigDataHolder) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Lazy(org.springframework.context.annotation.Lazy) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 5 with LocalContainerEntityManagerFactoryBean

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;
}
Also used : JpaConfigDataHolder(org.apereo.cas.configuration.model.support.jpa.JpaConfigDataHolder) SamlIdPMetadataProperties(org.apereo.cas.configuration.model.support.saml.idp.metadata.SamlIdPMetadataProperties) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Lazy(org.springframework.context.annotation.Lazy) OpenSamlConfigBean(org.apereo.cas.support.saml.OpenSamlConfigBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)75 Bean (org.springframework.context.annotation.Bean)63 HibernateJpaVendorAdapter (org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter)42 Properties (java.util.Properties)14 JpaVendorAdapter (org.springframework.orm.jpa.JpaVendorAdapter)7 HashMap (java.util.HashMap)4 JpaConfigDataHolder (org.apereo.cas.configuration.model.support.jpa.JpaConfigDataHolder)4 Test (org.junit.jupiter.api.Test)4 DependsOn (org.springframework.context.annotation.DependsOn)4 Lazy (org.springframework.context.annotation.Lazy)4 AbstractJpaProperties (org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties)2 DatabaseProperties (org.apereo.cas.configuration.model.support.jpa.DatabaseProperties)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Primary (org.springframework.context.annotation.Primary)2 DefaultPersistenceUnitManager (org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager)2 DatabaseManager (com.fredboat.backend.quarterdeck.db.DatabaseManager)1 AugmentableQueryRepositoryFactoryBean (com.thinkbiganalytics.metadata.jpa.feed.AugmentableQueryRepositoryFactoryBean)1 DataSourceBean (de.alpharogroup.springconfig.DataSourceBean)1 JdbcUrlBean (de.alpharogroup.springconfig.JdbcUrlBean)1 PersistenceUnitInfo (jakarta.persistence.spi.PersistenceUnitInfo)1