Example usage for javax.persistence.spi PersistenceUnitTransactionType JTA

List of usage examples for javax.persistence.spi PersistenceUnitTransactionType JTA

Introduction

In this page you can find the example usage for javax.persistence.spi PersistenceUnitTransactionType JTA.

Prototype

PersistenceUnitTransactionType JTA

To view the source code for javax.persistence.spi PersistenceUnitTransactionType JTA.

Click Source Link

Document

JTA entity managers will be created.

Usage

From source file:org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.java

private void applyTransactionProperties() {
    PersistenceUnitTransactionType txnType = PersistenceUnitTransactionTypeHelper
            .interpretTransactionType(configurationValues.get(AvailableSettings.TRANSACTION_TYPE));
    if (txnType == null) {
        txnType = persistenceUnit.getTransactionType();
    }/*from  w w w .  j a v  a2s.  c o m*/
    if (txnType == null) {
        // is it more appropriate to have this be based on bootstrap entry
        // point (EE vs SE)?
        txnType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
    }
    settings.setTransactionType(txnType);
    boolean hasTxStrategy = configurationValues.containsKey(Environment.TRANSACTION_STRATEGY);
    if (hasTxStrategy) {
        LOG.overridingTransactionStrategyDangerous(Environment.TRANSACTION_STRATEGY);
    } else {
        if (txnType == PersistenceUnitTransactionType.JTA) {
            serviceRegistryBuilder.applySetting(Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class);
        } else if (txnType == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
            serviceRegistryBuilder.applySetting(Environment.TRANSACTION_STRATEGY, JdbcTransactionFactory.class);
        }
    }
}

From source file:org.jboss.ejb3.entity.PersistenceXmlLoader.java

public static PersistenceUnitTransactionType getTransactionType(String elementContent) {
    if (StringHelper.isEmpty(elementContent)) {
        return null; //PersistenceUnitTransactionType.JTA;
    } else if (elementContent.equalsIgnoreCase("JTA")) {
        return PersistenceUnitTransactionType.JTA;
    } else if (elementContent.equalsIgnoreCase("RESOURCE_LOCAL")) {
        return PersistenceUnitTransactionType.RESOURCE_LOCAL;
    } else {//from   w  ww  . j  av  a  2  s  .  c o m
        throw new PersistenceException("Unknown TransactionType: " + elementContent);
    }
}

From source file:org.kuali.rice.krad.data.jpa.eclipselink.KradEclipseLinkEntityManagerFactoryBeanTest.java

private boolean isJtaEnabled() throws Exception {
    EntityManagerFactoryDelegate delegate = entityManagerFactory.unwrap(EntityManagerFactoryDelegate.class);
    PersistenceUnitInfo info = delegate.getSetupImpl().getPersistenceUnitInfo();
    return info.getJtaDataSource() != null && info.getTransactionType() == PersistenceUnitTransactionType.JTA;
}

From source file:org.springframework.orm.jpa.ExtendedEntityManagerCreator.java

/**
 * Actually create the EntityManager proxy.
 * @param rawEntityManager raw EntityManager
 * @param emfInfo the EntityManagerFactoryInfo to obtain the JpaDialect
 * and PersistenceUnitInfo from//  w  w w  .ja  v  a  2  s  .  c om
 * @param containerManaged whether to follow container-managed EntityManager
 * or application-managed EntityManager semantics
 * @param synchronizedWithTransaction whether to automatically join ongoing
 * transactions (according to the JPA 2.1 SynchronizationType rules)
 * @return the EntityManager proxy
 */
private static EntityManager createProxy(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo,
        boolean containerManaged, boolean synchronizedWithTransaction) {

    Assert.notNull(emfInfo, "EntityManagerFactoryInfo must not be null");
    JpaDialect jpaDialect = emfInfo.getJpaDialect();
    PersistenceUnitInfo pui = emfInfo.getPersistenceUnitInfo();
    Boolean jta = (pui != null ? pui.getTransactionType() == PersistenceUnitTransactionType.JTA : null);
    return createProxy(rawEntityManager, emfInfo.getEntityManagerInterface(), emfInfo.getBeanClassLoader(),
            jpaDialect, jta, containerManaged, synchronizedWithTransaction);
}

From source file:org.wisdom.framework.jpa.PersistenceUnitComponent.java

@Override
public PersistenceUnitTransactionType getTransactionType() {
    if (persistenceUnitXml
            .getTransactionType() == org.wisdom.framework.jpa.model.PersistenceUnitTransactionType.RESOURCE_LOCAL) {
        return PersistenceUnitTransactionType.RESOURCE_LOCAL;
    } else {//from   w w  w  .j  av a2s  . c  o  m
        return PersistenceUnitTransactionType.JTA;
    }
}