Example usage for org.hibernate.cfg AvailableSettings TRANSACTION_COORDINATOR_STRATEGY

List of usage examples for org.hibernate.cfg AvailableSettings TRANSACTION_COORDINATOR_STRATEGY

Introduction

In this page you can find the example usage for org.hibernate.cfg AvailableSettings TRANSACTION_COORDINATOR_STRATEGY.

Prototype

String TRANSACTION_COORDINATOR_STRATEGY

To view the source code for org.hibernate.cfg AvailableSettings TRANSACTION_COORDINATOR_STRATEGY.

Click Source Link

Document

Names the implementation of TransactionCoordinatorBuilder to use for creating TransactionCoordinator instances.

Usage

From source file:org.jboss.additional.testsuite.jdkall.past.jpa.hibernate.secondlevelcache.SFSB.java

License:Open Source License

@TransactionAttribute(TransactionAttributeType.NEVER)
public void setupConfig() {
    // static {/*  w w  w  .j ava  2s  . c o  m*/
    try {

        // prepare the configuration
        Configuration configuration = new Configuration()
                .setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
        configuration.getProperties().put(AvailableSettings.JTA_PLATFORM, JBossAppServerJtaPlatform.class);
        configuration.getProperties().put(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta");
        configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
        configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS");
        // fetch the properties
        Properties properties = new Properties();
        configuration = configuration.configure("hibernate.cfg.xml");
        properties.putAll(configuration.getProperties());
        Environment.verifyProperties(properties);
        ConfigurationHelper.resolvePlaceHolders(properties);

        sessionFactory = configuration.buildSessionFactory();

    } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed
        ex.printStackTrace();
        throw new ExceptionInInitializerError(ex);
    }
}