Search in sources :

Example 56 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project Logos_Materials_October_2017 by VolodymyrZavada.

the class DatabaseConfig method getTransactionManager.

@Bean(name = "transactionManager")
@Autowired
public PlatformTransactionManager getTransactionManager(EntityManagerFactory emf) throws NamingException {
    JpaTransactionManager jpaTransaction = new JpaTransactionManager();
    jpaTransaction.setEntityManagerFactory(emf);
    return jpaTransaction;
}
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 57 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project Logos_Materials_October_2017 by VolodymyrZavada.

the class DatabaseConfig method getTransactionManager.

@Bean(name = "transactionManager")
@Autowired
public PlatformTransactionManager getTransactionManager(EntityManagerFactory emf) throws NamingException {
    JpaTransactionManager jpaTransaction = new JpaTransactionManager();
    jpaTransaction.setEntityManagerFactory(emf);
    return jpaTransaction;
}
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 58 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850PersistenceConfig method transactionManager.

/**
     * Method for creating the Transaction Manager.
     *
     * @return JpaTransactionManager
     * @throws ClassNotFoundException
     *             when class not found
     */
@Bean
public JpaTransactionManager transactionManager() throws ProtocolAdapterException {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();
    try {
        transactionManager.setEntityManagerFactory(this.iec61850EntityManagerFactory().getObject());
        transactionManager.setTransactionSynchronization(JpaTransactionManager.SYNCHRONIZATION_ALWAYS);
    } catch (final ClassNotFoundException e) {
        final String msg = "Error in creating transaction manager bean";
        LOGGER.error(msg, e);
        throw new ProtocolAdapterException(msg, e);
    }
    return transactionManager;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 59 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project crnk-framework by crnk-project.

the class JpaTestConfig method transactionManager.

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

Example 60 with JpaTransactionManager

use of org.springframework.orm.jpa.JpaTransactionManager in project crnk-framework by crnk-project.

the class OperationsTestConfig method transactionManager.

@Bean
public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(emf);
    transactionManager.setDataSource(testDataSource());
    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