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

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

Introduction

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

Prototype

public void setEntityManagerFactory(@Nullable EntityManagerFactory emf) 

Source Link

Document

Set the EntityManagerFactory that this instance should manage transactions for.

Usage

From source file:de.hska.ld.core.config.PersistenceConfig.java

@Bean
public PlatformTransactionManager transactionManager() throws SQLException {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return txManager;
}

From source file:net.ljcomputing.sr.config.JpaConfiguration.java

/**
 * Configured transaction manager bean.//  w ww. j a v a  2  s  .  c om
 *
 * @param entityManagerFactory the entity manager factory
 * @return the platform transaction manager
 */
@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory);
    return transactionManager;
}

From source file:com.alliander.osgp.core.db.api.application.config.OsgpCoreDbApiPersistenceConfig.java

/**
 * Method for creating the Transaction Manager.
 *
 * @return JpaTransactionManager/*from  w  w  w  .j  a  v a  2  s. c  o m*/
 * @throws ClassNotFoundException
 *             when class not found
 */
@Bean
public JpaTransactionManager osgpCoreDbApiTransactionManager() throws CoreDbApiException {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();

    try {
        transactionManager.setEntityManagerFactory(this.osgpCoreDbApiEntityManagerFactory().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 CoreDbApiException(msg, e);
    }

    return transactionManager;
}

From source file:com.alliander.osgp.core.db.api.iec61850.application.config.Iec61850OsgpCoreDbApiPersistenceConfig.java

/**
 * Method for creating the Transaction Manager.
 *
 * @return JpaTransactionManager//from ww  w.  j a  va 2s.co  m
 * @throws ClassNotFoundException
 *             when class not found
 */
@Bean
public JpaTransactionManager iec61850OsgpCoreDbApiTransactionManager() throws Iec61850CoreDbApiException {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();

    try {
        transactionManager
                .setEntityManagerFactory(this.iec61850OsgpCoreDbApiEntityManagerFactory().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 Iec61850CoreDbApiException(msg, e);
    }

    return transactionManager;
}

From source file:be.bittich.quote.config.SpringJPAConfig.java

/**
 * Transaction Manager bean//  w  ww.j  a va  2s  . c  o  m
 *
 * @param entityManagerFactory
 * @return
 */
@Bean
@Autowired
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager txManager = new JpaTransactionManager();
    JpaDialect jpaDialect = new HibernateJpaDialect();
    txManager.setEntityManagerFactory(entityManagerFactory);
    txManager.setJpaDialect(jpaDialect);
    return txManager;
}

From source file:ru.anr.base.dao.AbstractJPADaoConfig.java

/**
 * {@inheritDoc}//from www  . j  a va  2 s .  c  o  m
 */
@Override
@Bean(name = "transactionManager")
public PlatformTransactionManager transactionManager() {

    JpaTransactionManager txManager = new JpaTransactionManager();

    txManager.setEntityManagerFactory(entityManagerFactory());
    txManager.setDataSource(dataSource());
    return txManager;
}

From source file:com.amuponda.estorehack.business.config.EstoreHackDataConfig.java

@Bean
public JpaTransactionManager transactionManager() {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    //EntityManagerFactory is first retrieved from its bean factory and then passed to the transaction manager
    transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return transactionManager;
}

From source file:cz.lbenda.coursing.client.ClientAppConfig.java

public @Bean PlatformTransactionManager transactionManager() {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(entityManagerFactory());
    return txManager;
}

From source file:org.osgp.adapter.protocol.dlms.application.config.DlmsPersistenceConfig.java

/**
 * Method for creating the Transaction Manager.
 *
 * @return JpaTransactionManager//www.ja  v a 2s.  c  o m
 * @throws ClassNotFoundException
 *             when class not found
 */
@Bean
public JpaTransactionManager transactionManager() throws ProtocolAdapterException {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();

    try {
        transactionManager.setEntityManagerFactory(this.dlmsEntityManagerFactory().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;
}

From source file:com.dominion.salud.mpr.configuration.MPRJpaConfiguration.java

@Bean
@Autowired/* ww  w .jav  a 2  s  .  co  m*/
public JpaTransactionManager transactionManager() {
    JpaTransactionManager txManager = new JpaTransactionManager();
    JpaDialect jpaDialect = new HibernateJpaDialect();
    txManager.setEntityManagerFactory(entityManagerFactory());
    txManager.setJpaDialect(jpaDialect);
    return txManager;
}