Search in sources :

Example 31 with LocalContainerEntityManagerFactoryBean

use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project Activiti by Activiti.

the class DatabaseConfiguration method entityManagerFactory.

@Bean(name = "entityManagerFactory")
public EntityManagerFactory entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan("org.activiti.rest.api.jpa.model");
    entityManagerFactoryBean.setPersistenceUnitName("test");
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    hibernateJpaVendorAdapter.setShowSql(false);
    hibernateJpaVendorAdapter.setGenerateDdl(true);
    hibernateJpaVendorAdapter.setDatabase(Database.H2);
    entityManagerFactoryBean.setJpaVendorAdapter(hibernateJpaVendorAdapter);
    entityManagerFactoryBean.afterPropertiesSet();
    return entityManagerFactoryBean.getObject();
}
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 32 with LocalContainerEntityManagerFactoryBean

use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850OsgpCoreDbApiPersistenceConfig method iec61850OsgpCoreDbApiEntityManagerFactory.

/**
     * Method for creating the Entity Manager Factory Bean.
     *
     * @return LocalContainerEntityManagerFactoryBean
     * @throws ClassNotFoundException
     *             when class not found
     */
@Bean
public LocalContainerEntityManagerFactoryBean iec61850OsgpCoreDbApiEntityManagerFactory() throws ClassNotFoundException {
    final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setPersistenceUnitName("OSGP_CORE_DB_API_IEC61850");
    entityManagerFactoryBean.setDataSource(this.getOsgpCoreDbApiDataSource());
    entityManagerFactoryBean.setPackagesToScan(ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
    final Properties jpaProperties = new Properties();
    jpaProperties.put(HIBERNATE_DIALECT_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT_VALUE));
    jpaProperties.put(HIBERNATE_FORMAT_SQL_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL_VALUE));
    jpaProperties.put(HIBERNATE_NAMING_STRATEGY_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY_VALUE));
    jpaProperties.put(HIBERNATE_SHOW_SQL_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL_VALUE));
    entityManagerFactoryBean.setJpaProperties(jpaProperties);
    return entityManagerFactoryBean;
}
Also used : Properties(java.util.Properties) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 33 with LocalContainerEntityManagerFactoryBean

use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cas by apereo.

the class JpaBeans 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().toArray(new String[] {}));
    if (config.getDataSource() != null) {
        bean.setDataSource(config.getDataSource());
    }
    final Properties properties = new Properties();
    properties.put(Environment.DIALECT, jpaProperties.getDialect());
    properties.put(Environment.HBM2DDL_AUTO, jpaProperties.getDdlAuto());
    properties.put(Environment.STATEMENT_BATCH_SIZE, jpaProperties.getBatchSize());
    if (StringUtils.isNotBlank(jpaProperties.getDefaultCatalog())) {
        properties.put(Environment.DEFAULT_CATALOG, jpaProperties.getDefaultCatalog());
    }
    if (StringUtils.isNotBlank(jpaProperties.getDefaultSchema())) {
        properties.put(Environment.DEFAULT_SCHEMA, jpaProperties.getDefaultSchema());
    }
    properties.put(Environment.ENABLE_LAZY_LOAD_NO_TRANS, Boolean.TRUE);
    properties.put(Environment.FORMAT_SQL, Boolean.TRUE);
    properties.putAll(jpaProperties.getProperties());
    bean.setJpaProperties(properties);
    return bean;
}
Also used : Properties(java.util.Properties) AbstractJpaProperties(org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties) DatabaseProperties(org.apereo.cas.configuration.model.support.jpa.DatabaseProperties) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 34 with LocalContainerEntityManagerFactoryBean

use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project av-service by dvoraka.

the class DbConfig method entityManagerFactory.

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan("dvoraka.avservice.db.model");
    entityManagerFactoryBean.setJpaProperties(hibernateProperties());
    return entityManagerFactoryBean;
}
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 35 with LocalContainerEntityManagerFactoryBean

use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project perry by ca-cwds.

the class CMSConfiguration method entityManagerFactory.

@Bean
@Primary
@Autowired
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setJpaPropertyMap(jpaProperties().getHibernateProperties(dataSource));
    em.setPackagesToScan("gov.ca.cwds.data.persistence.auth", "gov.ca.cwds.data.auth");
    em.setPersistenceUnitName("default");
    em.setJpaVendorAdapter(jpaVendorAdapter());
    return em;
}
Also used : LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Autowired(org.springframework.beans.factory.annotation.Autowired) Primary(org.springframework.context.annotation.Primary) 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