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

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

Introduction

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

Prototype

public final void setTransactionSynchronization(int transactionSynchronization) 

Source Link

Document

Set when this transaction manager should activate the thread-bound transaction synchronization support.

Usage

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 a2 s. c  om*/
 * @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:org.osgp.adapter.protocol.dlms.application.config.DlmsPersistenceConfig.java

/**
 * Method for creating the Transaction Manager.
 *
 * @return JpaTransactionManager//w ww.  ja v a2  s .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.alliander.osgp.adapter.protocol.oslp.application.config.OslpPersistenceConfig.java

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

    try {
        transactionManager.setEntityManagerFactory(this.oslpEntityManagerFactory().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.alliander.osgp.core.db.api.iec61850.application.config.Iec61850OsgpCoreDbApiPersistenceConfig.java

/**
 * Method for creating the Transaction Manager.
 *
 * @return JpaTransactionManager/*from  w  w  w.  ja  va2s . c o 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;
}