List of usage examples for org.hibernate.cfg AvailableSettings RELEASE_CONNECTIONS
String RELEASE_CONNECTIONS
To view the source code for org.hibernate.cfg AvailableSettings RELEASE_CONNECTIONS.
Click Source Link
From source file:debop4k.data.orm.spring.boot.autoconfigure.HibernateProperties.java
License:Apache License
@SneakyThrows({ IOException.class }) public Properties toProperties() { Properties props = new Properties(); props.put(AvailableSettings.DIALECT, dialect); props.put(AvailableSettings.HBM2DDL_AUTO, hbm2ddl); props.put(AvailableSettings.SHOW_SQL, showSql); props.put(AvailableSettings.FORMAT_SQL, formatSql); props.put(AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, batchFetchSize); if (Stringx.isNotEmpty(isolation)) { props.put(AvailableSettings.ISOLATION, isolation); }// w w w. j av a 2s .c o m props.put(AvailableSettings.AUTOCOMMIT, autoCommit); props.put(AvailableSettings.RELEASE_CONNECTIONS, releaseMode); props.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, useSecondCache); props.put(AvailableSettings.CACHE_PROVIDER_CONFIG, cacheProviderConfig.getFile().getAbsolutePath()); return props; }
From source file:org.efaps.bpm.BPM.java
License:Apache License
/** * Initialize BPM.// ww w . j a va 2 s . co m * * @throws EFapsException on error */ public static void initialize() throws EFapsException { final SystemConfiguration config = EFapsSystemConfiguration.get(); final boolean active = config != null ? config.getAttributeValueAsBoolean(KernelSettings.ACTIVATE_BPM) : false; if (active) { if (BPM.PMANAGER != null) { BPM.PMANAGER.close(); BPM.PMANAGER = null; } if (BPM.SMANAGER != null) { BPM.SMANAGER.close(); BPM.SMANAGER = null; } UserTransaction userTrans = null; InitialContext context = null; try { context = new InitialContext(); userTrans = TransactionHelper.findUserTransaction(); Object object = null; try { object = context.lookup(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME); } catch (final NamingException ex) { BPM.LOG.info("Checked for JtaTransactionManager"); } if (object == null) { context.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, userTrans); context.bind(JtaTransactionManager.FALLBACK_TRANSACTION_MANAGER_NAMES[0], TransactionHelper.findTransactionManager()); } } catch (final NamingException ex) { BPM.LOG.error("Could not initialise JNDI InitialContext", ex); } // register our own KnowledgeBuilderFactoryService ServiceRegistryImpl.getInstance().addDefault(KnowledgeBuilderFactoryService.class, KnowledgeBuilderFactoryServiceImpl.class.getName()); final RegisterableItemsFactoryImpl itemsFactory = new RegisterableItemsFactoryImpl(); itemsFactory.addWorkItemHandler("Manual Task", ManualTaskItemHandler.class); itemsFactory.addProcessListener(WorkingMemoryLogListener.class); final Map<String, String> properties = new HashMap<String, String>(); properties.put(AvailableSettings.DIALECT, Context.getDbType().getHibernateDialect()); properties.put(AvailableSettings.SHOW_SQL, String.valueOf(BPM.LOG.isDebugEnabled())); properties.put(AvailableSettings.FORMAT_SQL, "true"); properties.put(AvailableSettings.RELEASE_CONNECTIONS, "after_transaction"); properties.put(AvailableSettings.CONNECTION_PROVIDER, ConnectionProvider.class.getName()); properties.put(org.hibernate.jpa.AvailableSettings.NAMING_STRATEGY, NamingStrategy.class.getName()); final EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa", properties); final RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.getDefault() .classLoader(EFapsClassLoader.getInstance()).userGroupCallback(new UserGroupCallbackImpl()) .entityManagerFactory(emf).registerableItemsFactory(itemsFactory).persistence(true) .addEnvironmentEntry("TRANSACTION_LOCK_ENABLED", "false"); BPM.add2EnvironmentBuilder(builder); final RuntimeEnvironment environment = builder.get(); final ManagerFactoryImpl factory = new ManagerFactoryImpl(); BPM.PMANAGER = factory.newPerProcessInstanceRuntimeManager(environment); BPM.SMANAGER = factory.newSingletonRuntimeManager(environment); } }