Search in sources :

Example 6 with JpaTransactionManager

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

the class BatchAutoConfigurationTests method testCustomizeJpaTransactionManagerUsingProperties.

@Test
public void testCustomizeJpaTransactionManagerUsingProperties() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.transaction.default-timeout:30", "spring.transaction.rollback-on-commit-failure:true");
    this.context.register(TestConfiguration.class, EmbeddedDataSourceConfiguration.class, HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class, TransactionAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    this.context.getBean(BatchConfigurer.class);
    JpaTransactionManager transactionManager = JpaTransactionManager.class.cast(this.context.getBean(BatchConfigurer.class).getTransactionManager());
    assertThat(transactionManager.getDefaultTimeout()).isEqualTo(30);
    assertThat(transactionManager.isRollbackOnCommitFailure()).isTrue();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Test(org.junit.Test)

Example 7 with JpaTransactionManager

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

the class HibernateJpaAutoConfigurationTests method testCustomJpaTransactionManagerUsingProperties.

@Test
public void testCustomJpaTransactionManagerUsingProperties() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "spring.transaction.default-timeout:30", "spring.transaction.rollback-on-commit-failure:true");
    setupTestConfiguration();
    this.context.refresh();
    JpaTransactionManager transactionManager = this.context.getBean(JpaTransactionManager.class);
    assertThat(transactionManager.getDefaultTimeout()).isEqualTo(30);
    assertThat(transactionManager.isRollbackOnCommitFailure()).isTrue();
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Test(org.junit.Test)

Example 8 with JpaTransactionManager

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

the class DataConfiguration method transactionManager.

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

Example 9 with JpaTransactionManager

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

the class JdbcMultifactorAuthnTrustConfiguration method transactionManagerMfaAuthnTrust.

@Autowired
@Bean
public PlatformTransactionManager transactionManagerMfaAuthnTrust(@Qualifier("mfaTrustedAuthnEntityManagerFactory") final EntityManagerFactory emf) {
    final JpaTransactionManager mgmr = new JpaTransactionManager();
    mgmr.setEntityManagerFactory(emf);
    return mgmr;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Autowired(org.springframework.beans.factory.annotation.Autowired) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 10 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project camel by apache.

the class JpaEndpoint method createTransactionManager.

protected PlatformTransactionManager createTransactionManager() {
    JpaTransactionManager tm = new JpaTransactionManager(getEntityManagerFactory());
    tm.afterPropertiesSet();
    return tm;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager)

Aggregations

JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)70 Bean (org.springframework.context.annotation.Bean)54 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)54 Autowired (org.springframework.beans.factory.annotation.Autowired)12 EntityManagerFactory (javax.persistence.EntityManagerFactory)8 Test (org.junit.Test)5 Primary (org.springframework.context.annotation.Primary)5 EntityManagerHolder (org.springframework.orm.jpa.EntityManagerHolder)4 EntityManager (javax.persistence.EntityManager)3 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)3 Stack (java.util.Stack)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)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 LoggingDelegateTransactionManager (de.invesdwin.context.persistence.jpa.scanning.transaction.LoggingDelegateTransactionManager)1 EntityManager (jakarta.persistence.EntityManager)1 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)1 EntityTransaction (jakarta.persistence.EntityTransaction)1 PrintWriter (java.io.PrintWriter)1