Search in sources :

Example 61 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project kylo by Teradata.

the class OperationalMetadataConfig method transactionManager.

/**
 * Return the entity manager
 * the datasource bean is configured in the base services application
 *
 * @param dataSource the datasource to use as the connection for the entity manager
 * @return the entity manager
 */
/*@Bean(name = "operationalMetadataJpaEntityManager")
    public EntityManager entityManager(@Qualifier("dataSource") DataSource dataSource) {
        return entityManagerFactory(dataSource).createEntityManager();
    }*/
/**
 * Return the JPA transaction manager
 *
 * @return the JPA transaction manager
 */
@Bean(name = "operationalMetadataTransactionManager")
public PlatformTransactionManager transactionManager(@Qualifier("dataSource") DataSource dataSource) {
    JpaTransactionManager xtnMgr = new JpaTransactionManager(entityManagerFactory(dataSource));
    xtnMgr.setDataSource(dataSource);
    xtnMgr.setTransactionSynchronization(AbstractPlatformTransactionManager.SYNCHRONIZATION_ALWAYS);
    return xtnMgr;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) AugmentableQueryRepositoryFactoryBean(com.thinkbiganalytics.metadata.jpa.feed.AugmentableQueryRepositoryFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 62 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project spring-boot by spring-projects.

the class JpaBaseConfiguration method transactionManager.

@Bean
@ConditionalOnMissingBean(TransactionManager.class)
public PlatformTransactionManager transactionManager(ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManagerCustomizers.ifAvailable((customizers) -> customizers.customize(transactionManager));
    return transactionManager;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingFilterBean(org.springframework.boot.autoconfigure.web.servlet.ConditionalOnMissingFilterBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 63 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project spring-boot by spring-projects.

the class HibernateJpaAutoConfigurationTests method jtaCustomTransactionManagerUsingProperties.

@Test
void jtaCustomTransactionManagerUsingProperties() {
    contextRunner().withPropertyValues("spring.transaction.default-timeout:30", "spring.transaction.rollback-on-commit-failure:true").run((context) -> {
        JpaTransactionManager transactionManager = context.getBean(JpaTransactionManager.class);
        assertThat(transactionManager.getDefaultTimeout()).isEqualTo(30);
        assertThat(transactionManager.isRollbackOnCommitFailure()).isTrue();
    });
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Test(org.junit.jupiter.api.Test)

Example 64 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project flytecnologia-api by jullierme.

the class FlyHibernateConfig method transactionManager.

@Bean
@Primary
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(emf);
    return transactionManager;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 65 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project tutorials by eugenp.

the class MySQLAutoconfiguration method transactionManager.

@Bean
@ConditionalOnMissingBean(type = "JpaTransactionManager")
JpaTransactionManager transactionManager(final EntityManagerFactory entityManagerFactory) {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory);
    return transactionManager;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)76 Bean (org.springframework.context.annotation.Bean)59 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)57 Autowired (org.springframework.beans.factory.annotation.Autowired)12 EntityManagerFactory (javax.persistence.EntityManagerFactory)8 Primary (org.springframework.context.annotation.Primary)7 Test (org.junit.Test)4 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)4 EntityManagerHolder (org.springframework.orm.jpa.EntityManagerHolder)4 EntityManager (javax.persistence.EntityManager)3 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)3 Stack (java.util.Stack)2 Test (org.junit.jupiter.api.Test)2 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 Iec61850CoreDbApiException (com.alliander.osgp.core.db.api.iec61850.exceptions.Iec61850CoreDbApiException)1 AugmentableQueryRepositoryFactoryBean (com.thinkbiganalytics.metadata.jpa.feed.AugmentableQueryRepositoryFactoryBean)1 EntityManager (jakarta.persistence.EntityManager)1 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)1 EntityTransaction (jakarta.persistence.EntityTransaction)1 PrintWriter (java.io.PrintWriter)1