Search in sources :

Example 1 with JpaDialect

use of org.springframework.orm.jpa.JpaDialect in project invesdwin-context-persistence by subes.

the class PersistenceUnitContext method createTransactionManager.

private PlatformTransactionManager createTransactionManager() {
    final JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
    jpaTransactionManager.setEntityManagerFactory(getEntityManagerFactory());
    final JpaDialect jpaDialect = getJpaDialect();
    if (jpaDialect != null) {
        jpaTransactionManager.setJpaDialect(jpaDialect);
    }
    final LoggingDelegateTransactionManager loggingDelegateTransactionManager = new LoggingDelegateTransactionManager(this, jpaTransactionManager);
    final String transactionManagerBeanName = getPersistenceUnitName() + PersistenceProperties.TRANSACTION_MANAGER_NAME_SUFFIX;
    MergedContext.getInstance().registerBean(transactionManagerBeanName, loggingDelegateTransactionManager);
    Assertions.assertThat(MergedContext.getInstance().getBean(transactionManagerBeanName)).isNotNull();
    return loggingDelegateTransactionManager;
}
Also used : JpaDialect(org.springframework.orm.jpa.JpaDialect) JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) LoggingDelegateTransactionManager(de.invesdwin.context.persistence.jpa.scanning.transaction.LoggingDelegateTransactionManager)

Example 2 with JpaDialect

use of org.springframework.orm.jpa.JpaDialect in project invesdwin-context-persistence by subes.

the class PersistenceUnitContext method createEntityManagerFactory.

private EntityManagerFactory createEntityManagerFactory() {
    Assertions.assertThat(persistenceUnitContextManager.isValidPersistenceUnit(persistenceUnitName)).as("Not a valid persistence unit: %s", persistenceUnitName).isTrue();
    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPersistenceUnitManager(persistenceUnitManager);
    factory.setPersistenceUnitName(persistenceUnitName);
    final JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter();
    if (jpaVendorAdapter != null) {
        factory.setJpaVendorAdapter(jpaVendorAdapter);
    } else {
        factory.setPersistenceProvider(getPersistenceProvider());
    }
    final JpaDialect jpaDialect = getJpaDialect();
    if (jpaDialect != null) {
        factory.setJpaDialect(jpaDialect);
    }
    factory.afterPropertiesSet();
    final String entityManagerFactoryBeanName = getPersistenceUnitName() + PersistenceProperties.ENTITY_MANAGER_FACTORY_NAME_SUFFIX;
    MergedContext.getInstance().registerBean(entityManagerFactoryBeanName, factory);
    Assertions.assertThat(MergedContext.getInstance().getBean(entityManagerFactoryBeanName)).isNotNull();
    return factory.getObject();
}
Also used : JpaDialect(org.springframework.orm.jpa.JpaDialect) JpaVendorAdapter(org.springframework.orm.jpa.JpaVendorAdapter) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

JpaDialect (org.springframework.orm.jpa.JpaDialect)2 LoggingDelegateTransactionManager (de.invesdwin.context.persistence.jpa.scanning.transaction.LoggingDelegateTransactionManager)1 JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)1 JpaVendorAdapter (org.springframework.orm.jpa.JpaVendorAdapter)1 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)1