Example usage for org.springframework.orm.jpa JpaTransactionManager JpaTransactionManager

List of usage examples for org.springframework.orm.jpa JpaTransactionManager JpaTransactionManager

Introduction

In this page you can find the example usage for org.springframework.orm.jpa JpaTransactionManager JpaTransactionManager.

Prototype

public JpaTransactionManager(EntityManagerFactory emf) 

Source Link

Document

Create a new JpaTransactionManager instance.

Usage

From source file:com.dcsbootcamp.maven.fixture.PostgresTestConfig.java

/**
 * Provides JPA based Spring transaction manager.
 *
 * @param emf the entity manager factory
 * @return jpa transaction manager/*from   ww w .  j  a  v  a2  s. c  om*/
 */
@Bean
JpaTransactionManager jpaTransactionManagerProvider(EntityManagerFactory emf) {
    JpaTransactionManager transactionManager = new JpaTransactionManager(emf);

    return transactionManager;
}

From source file:fr.univlorraine.mondossierweb.config.JpaConfig.java

/**
 * Transaction Manager/*from   ww  w .  j av  a 2  s .co m*/
 * @return
 */
@Bean
public JpaTransactionManager transactionManager() {
    return new JpaTransactionManager(entityManagerFactory().getObject());
}

From source file:com.otterca.persistence.dao.H2Configuration.java

/**
 * Get transaction manager for this entity manager factory.
 * //from  ww  w  .ja  va2s .  c  o  m
 * @return
 */
@Bean
public JpaTransactionManager getTransactionManager() {
    if (txMgr == null) {
        synchronized (this) {
            if (txMgr == null) {
                txMgr = new JpaTransactionManager(getEntityManagerFactory().getObject());
            }
        }
    }
    return txMgr;
}

From source file:com.mycompany.projetsportmanager.spring.configuration.BaseConfiguration.java

/**
 * Builds the persistence unit manager.//from w w w .  j a  va 2s .  c o m
 * @param dataSource the datasource.
 * @return the persistence unit manager.
 */
@Bean
public PlatformTransactionManager myTxManager() {
    return new JpaTransactionManager(myEmf().getObject());
}

From source file:ru.develgame.jflickrorganizer.MainClass.java

@Bean
public JpaTransactionManager transactionManager() {
    return new JpaTransactionManager(entityManagerFactory());
}

From source file:org.activiti.spring.test.jpa.JPASpringTest.java

@Bean
public PlatformTransactionManager jpaTransactionManager(EntityManagerFactory entityManagerFactory) {
    return new JpaTransactionManager(entityManagerFactory);
}

From source file:org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.java

protected PlatformTransactionManager createTransactionManager() {
    if (this.entityManagerFactory != null) {
        return new JpaTransactionManager(this.entityManagerFactory);
    }//from   w ww. ja v  a  2s  .  co  m
    return new DataSourceTransactionManager(this.dataSource);
}

From source file:org.springframework.boot.autoconfigure.batch.JpaBatchConfigurer.java

@Override
protected PlatformTransactionManager createTransactionManager() {
    return new JpaTransactionManager(this.entityManagerFactory);
}

From source file:org.unitils.orm.jpa.JpaModule.java

public void registerTransactionManagementConfiguration() {
    // Make sure that a spring JpaTransactionManager is used for transaction management in the database module, if the
    // current test object defines a JPA EntityManagerFactory
    for (final DataSourceWrapper wrapper : wrappers) {
        getDatabaseModule()//from  w  w w  . ja v a 2  s.com
                .registerTransactionManagementConfiguration(new UnitilsTransactionManagementConfiguration() {

                    public boolean isApplicableFor(Object testObject) {
                        return isPersistenceUnitConfiguredFor(testObject);
                    }

                    public PlatformTransactionManager getSpringPlatformTransactionManager(Object testObject) {
                        EntityManagerFactory entityManagerFactory = getPersistenceUnit(testObject);
                        JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(
                                entityManagerFactory);
                        jpaTransactionManager.setDataSource(getDataSource());
                        jpaTransactionManager
                                .setJpaDialect(jpaProviderSupport.getSpringJpaVendorAdaptor().getJpaDialect());
                        return jpaTransactionManager;
                    }

                    public boolean isTransactionalResourceAvailable(Object testObject) {
                        return wrapper.isDataSourceLoaded();
                    }

                    public Integer getPreference() {
                        return 10;
                    }

                });
    }

}