Search in sources :

Example 46 with JpaTransactionManager

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

the class JpaEndpointTest method testJpaEndpointCtrUrlEMFandTM.

/**
     * 
     * @deprecated
     */
@Deprecated
@Test
public void testJpaEndpointCtrUrlEMFandTM() throws Exception {
    EntityManagerFactory fac = Persistence.createEntityManagerFactory("camel");
    JpaTransactionManager tm = new JpaTransactionManager(fac);
    tm.afterPropertiesSet();
    JpaEndpoint jpa = new JpaEndpoint("jpa://org.apache.camel.examples.SendEmail", fac, tm);
    jpa.setEntityType(SendEmail.class);
    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 47 with JpaTransactionManager

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

the class JpaMessageIdRepository method createTransactionTemplate.

private static TransactionTemplate createTransactionTemplate(EntityManagerFactory entityManagerFactory) {
    TransactionTemplate transactionTemplate = new TransactionTemplate();
    transactionTemplate.setTransactionManager(new JpaTransactionManager(entityManagerFactory));
    transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    return transactionTemplate;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate)

Example 48 with JpaTransactionManager

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

the class SamlIdPJpaMetadataConfiguration method transactionManagerSamlMetadata.

@Autowired
@Bean
public PlatformTransactionManager transactionManagerSamlMetadata(@Qualifier("samlMetadataEntityManagerFactory") 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) OpenSamlConfigBean(org.apereo.cas.support.saml.OpenSamlConfigBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 49 with JpaTransactionManager

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

the class JpaServiceRegistryConfiguration method transactionManagerServiceReg.

@Autowired
@Bean
public PlatformTransactionManager transactionManagerServiceReg(@Qualifier("serviceEntityManagerFactory") 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 50 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project java-design-patterns by iluwatar.

the class AppConfig method transactionManager.

/**
 * Get transaction manager
 */
@Bean
public JpaTransactionManager transactionManager() throws SQLException {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return transactionManager;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Bean(org.springframework.context.annotation.Bean) 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