List of usage examples for org.hibernate.cfg AvailableSettings JTA_PLATFORM
String JTA_PLATFORM
To view the source code for org.hibernate.cfg AvailableSettings JTA_PLATFORM.
Click Source Link
From source file:org.springframework.orm.hibernate5.LocalSessionFactoryBuilder.java
License:Apache License
/** * Set the Spring {@link JtaTransactionManager} or the JTA {@link TransactionManager} * to be used with Hibernate, if any. Allows for using a Spring-managed transaction * manager for Hibernate 5's session and cache synchronization, with the * "hibernate.transaction.jta.platform" automatically set to it. * <p>A passed-in Spring {@link JtaTransactionManager} needs to contain a JTA * {@link TransactionManager} reference to be usable here, except for the WebSphere * case where we'll automatically set {@code WebSphereExtendedJtaPlatform} accordingly. * <p>Note: If this is set, the Hibernate settings should not contain a JTA platform * setting to avoid meaningless double configuration. *//* w ww. jav a 2 s .c om*/ public LocalSessionFactoryBuilder setJtaTransactionManager(Object jtaTransactionManager) { Assert.notNull(jtaTransactionManager, "Transaction manager reference must not be null"); if (jtaTransactionManager instanceof JtaTransactionManager) { boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader()); if (webspherePresent) { getProperties().put(AvailableSettings.JTA_PLATFORM, "org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform"); } else { JtaTransactionManager jtaTm = (JtaTransactionManager) jtaTransactionManager; if (jtaTm.getTransactionManager() == null) { throw new IllegalArgumentException( "Can only apply JtaTransactionManager which has a TransactionManager reference set"); } getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction(), jtaTm.getTransactionSynchronizationRegistry())); } } else if (jtaTransactionManager instanceof TransactionManager) { getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null, null)); } else { throw new IllegalArgumentException( "Unknown transaction manager type: " + jtaTransactionManager.getClass().getName()); } return this; }
From source file:org.wildfly.extension.picketlink.idm.service.JPAIdentityStoreService.java
License:Open Source License
private EntityManagerFactory createEmbeddedEntityManagerFactory() { ROOT_LOGGER.debugf("Creating embedded EntityManagerFactory."); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try {/*from ww w . j av a 2 s .c om*/ Map<Object, Object> properties = new HashMap<Object, Object>(); String dataSourceJndiUrl = this.storeConfig.getDataSourceJndiUrl(); if (!isNullOrEmpty(dataSourceJndiUrl)) { ROOT_LOGGER.debugf("Using datasource [%s] for embedded EntityManagerFactory.", dataSourceJndiUrl); properties.put("javax.persistence.jtaDataSource", dataSourceJndiUrl); } properties.put(AvailableSettings.JTA_PLATFORM, new JBossAppServerJtaPlatform()); Module entityModule = this.storeConfig.getEntityModule(); if (entityModule != null) { Thread.currentThread().setContextClassLoader(entityModule.getClassLoader()); } return Persistence.createEntityManagerFactory(this.storeConfig.getEntityModuleUnitName(), properties); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
From source file:zcu.xutil.orm.SessionFactoryBean.java
License:Apache License
public SessionFactory getObject() { configure.getProperties().put(AvailableSettings.DATASOURCE, dataSource); configure.setProperty(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, XutilSessionContext.class.getName()); if (TxManager.getTxManager().getUserTransaction() != null) { configure.setProperty(AvailableSettings.JTA_PLATFORM, JTA.class.getName()); configure.setProperty(AvailableSettings.TRANSACTION_STRATEGY, JtaTransactionFactory.class.getName()); }//from w w w . j a va2 s . c o m ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configure.getProperties()) .buildServiceRegistry(); return configure.buildSessionFactory(serviceRegistry); }