Search in sources :

Example 11 with JpaTransactionManager

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

the class JpaComponentTest method testJpaComponentEMFandTM.

@Test
public void testJpaComponentEMFandTM() throws Exception {
    JpaComponent comp = new JpaComponent();
    comp.setCamelContext(context);
    assertNull(comp.getEntityManagerFactory());
    assertNull(comp.getTransactionManager());
    EntityManagerFactory fac = Persistence.createEntityManagerFactory("camel");
    JpaTransactionManager tm = new JpaTransactionManager(fac);
    tm.afterPropertiesSet();
    comp.setEntityManagerFactory(fac);
    comp.setTransactionManager(tm);
    assertSame(fac, comp.getEntityManagerFactory());
    assertSame(tm, comp.getTransactionManager());
    JpaEndpoint jpa = (JpaEndpoint) comp.createEndpoint("jpa://" + SendEmail.class.getName());
    assertNotNull(jpa);
    assertNotNull(jpa.getEntityType());
}
Also used : EntityManagerFactory(javax.persistence.EntityManagerFactory) JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) SendEmail(org.apache.camel.examples.SendEmail) Test(org.junit.Test)

Example 12 with JpaTransactionManager

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

the class JpaEndpointTest method testJpaEndpointCustomEMFandTM.

@Test
public void testJpaEndpointCustomEMFandTM() throws Exception {
    EntityManagerFactory fac = Persistence.createEntityManagerFactory("camel");
    JpaTransactionManager tm = new JpaTransactionManager(fac);
    tm.afterPropertiesSet();
    JpaEndpoint jpa = new JpaEndpoint();
    jpa.setEntityType(SendEmail.class);
    jpa.setEntityManagerFactory(fac);
    jpa.setTransactionManager(tm);
    assertSame(fac, jpa.getEntityManagerFactory());
    assertSame(tm, jpa.getTransactionManager());
    assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
    assertEquals("camel", jpa.getPersistenceUnit());
}
Also used : EntityManagerFactory(javax.persistence.EntityManagerFactory) JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Test(org.junit.Test)

Example 13 with JpaTransactionManager

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

the class JpaYubiKeyConfiguration method transactionManagerYubiKey.

@Autowired
@Bean
public PlatformTransactionManager transactionManagerYubiKey(@Qualifier("yubiKeyEntityManagerFactory") 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 14 with JpaTransactionManager

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

the class U2FJpaConfiguration method transactionManagerU2f.

@Autowired
@Bean
public PlatformTransactionManager transactionManagerU2f(@Qualifier("u2fEntityManagerFactory") 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 15 with JpaTransactionManager

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

the class CasConsentJdbcConfiguration method transactionManagerConsent.

@Autowired
@Bean
public PlatformTransactionManager transactionManagerConsent(@Qualifier("consentEntityManagerFactory") 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)

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