Search in sources :

Example 1 with JBossAppServerJtaPlatform

use of org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform in project wildfly by wildfly.

the class JPAIdentityStoreService method createEmbeddedEntityManagerFactory.

private EntityManagerFactory createEmbeddedEntityManagerFactory() {
    ROOT_LOGGER.debugf("Creating embedded EntityManagerFactory.");
    ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        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);
    }
}
Also used : HashMap(java.util.HashMap) Module(org.jboss.modules.Module) JBossAppServerJtaPlatform(org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform)

Aggregations

HashMap (java.util.HashMap)1 JBossAppServerJtaPlatform (org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform)1 Module (org.jboss.modules.Module)1