List of usage examples for org.apache.ibatis.session ExecutorType SIMPLE
ExecutorType SIMPLE
To view the source code for org.apache.ibatis.session ExecutorType SIMPLE.
Click Source Link
From source file:com.aspectran.mybatis.SqlSessionTxAdvice.java
License:Apache License
/** * Opens a new SqlSession and store its instance inside. Therefore, whenever * there is a request for a SqlSessionTxAdvice bean, a new bean instance of * the object must be created.//from w w w. j a va 2 s . c o m */ public void open() { if (sqlSession == null) { if (executorType == null) { executorType = ExecutorType.SIMPLE; } sqlSession = sqlSessionFactory.openSession(executorType, autoCommit); if (log.isDebugEnabled()) { ToStringBuilder tsb = new ToStringBuilder( String.format("%s %s@%x", (arbitrarilyClosed ? "Reopened" : "Opened"), sqlSession.getClass().getSimpleName(), sqlSession.hashCode())); tsb.append("executorType", executorType); tsb.append("autoCommit", autoCommit); log.debug(tsb.toString()); } arbitrarilyClosed = false; } }
From source file:com.dmm.framework.basedb.apache.ibatis.session.Configuration.java
License:Apache License
public Executor newExecutor(Transaction transaction, ExecutorType executorType) { executorType = executorType == null ? defaultExecutorType : executorType; executorType = executorType == null ? ExecutorType.SIMPLE : executorType; Executor executor;/*w w w . j av a2s . c om*/ if (ExecutorType.BATCH == executorType) { executor = new BatchExecutor(this, transaction); } else if (ExecutorType.REUSE == executorType) { executor = new ReuseExecutor(this, transaction); } else { executor = new SimpleExecutor(this, transaction); } if (cacheEnabled) { executor = new CachingExecutor(executor); } executor = (Executor) interceptorChain.pluginAll(executor); return executor; }
From source file:com.luxoft.mybatis.splitter.UpdateSplitterPluginTest.java
License:Apache License
@Test public void splitterTestSimple() throws IOException, SQLException { splitterTest(ExecutorType.SIMPLE); }
From source file:com.sinotopia.mybatis.mapper.mapperhelper.SelectKeyGenerator.java
License:Apache License
private void processGeneratedKeys(Executor executor, MappedStatement ms, Object parameter) { try {/*from w w w.j ava 2 s. c o m*/ if (parameter != null && keyStatement != null && keyStatement.getKeyProperties() != null) { String[] keyProperties = keyStatement.getKeyProperties(); final Configuration configuration = ms.getConfiguration(); final MetaObject metaParam = configuration.newMetaObject(parameter); if (keyProperties != null) { // Do not close keyExecutor. // The transaction will be closed by parent executor. Executor keyExecutor = configuration.newExecutor(executor.getTransaction(), ExecutorType.SIMPLE); List<Object> values = keyExecutor.query(keyStatement, parameter, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER); if (values.size() == 0) { throw new ExecutorException("SelectKey returned no data."); } else if (values.size() > 1) { throw new ExecutorException("SelectKey returned more than one value."); } else { MetaObject metaResult = configuration.newMetaObject(values.get(0)); if (keyProperties.length == 1) { if (metaResult.hasGetter(keyProperties[0])) { setValue(metaParam, keyProperties[0], metaResult.getValue(keyProperties[0])); } else { // no getter for the property - maybe just a single value object // so try that setValue(metaParam, keyProperties[0], values.get(0)); } } else { handleMultipleProperties(keyProperties, metaParam, metaResult); } } } } } catch (ExecutorException e) { throw e; } catch (Exception e) { throw new ExecutorException("Error selecting key or setting result to parameter object. Cause: " + e, e); } }
From source file:com.yimidida.shards.session.impl.ShardedSqlSessionFactoryImpl.java
License:Open Source License
@Override public ShardedSqlSession openSession(boolean autoCommit) { return this.openSession(ExecutorType.SIMPLE, autoCommit); }
From source file:com.yimidida.shards.session.impl.ShardedSqlSessionFactoryImpl.java
License:Open Source License
@Override public ShardedSqlSession openSession(TransactionIsolationLevel level) { return this.openSession(ExecutorType.SIMPLE, level); }
From source file:och.comp.db.base.BaseDb.java
License:Apache License
private CommitOnCloseSession openCommitOnCloseSession(boolean batch) { ExecutorType executorType = batch ? ExecutorType.BATCH : ExecutorType.SIMPLE; if (!isSingleTxMode()) { return new CommitOnCloseSession(sessionFactory.openSession(executorType)); }/*from ww w . ja v a 2s .c om*/ //SINGLE CONN MODE Environment env = sessionFactory.getConfiguration().getEnvironment(); DataSource ds = env.getDataSource(); Connection conn = null; try { conn = getSingleOrNewConnection(ds); } catch (Exception e) { throw new IllegalStateException("can't get conneciton", e); } return new CommitOnCloseSession(sessionFactory.openSession(executorType, conn)); }
From source file:org.jessma.dao.mybatis.MyBatisFacade.java
License:Apache License
/** ? {@link SqlSession} {@link ExecutorType} {@link ExecutorType#SIMPLE} */ protected void changeSessionExecutorTypeToSimple() { getManager().changeSessionExecutorType(ExecutorType.SIMPLE); }
From source file:org.mybatis.guice.configuration.ConfigurationProviderTest.java
License:Apache License
@Test public void get() { injector = Guice.createInjector(new AbstractModule() { @Override/*from w w w. j a v a 2 s . c o m*/ protected void configure() { bind(Environment.class).toInstance(environment); bind(DataSource.class).toInstance(dataSource); bind(Configuration.class).toProvider(configurationProvider); } }); Configuration configuration = injector.getInstance(Configuration.class); configuration.getMappedStatementNames(); // Test that configuration is valid. assertEquals(environment, configuration.getEnvironment()); assertNull(configuration.getTypeAliasRegistry().getTypeAliases().get("alias")); assertFalse(configuration.getTypeHandlerRegistry().hasTypeHandler(Alias.class)); assertFalse(configuration.getTypeHandlerRegistry().hasTypeHandler(Human.class)); assertEquals(0, configuration.getMapperRegistry().getMappers().size()); assertEquals(0, configuration.getInterceptors().size()); assertFalse(configuration.isLazyLoadingEnabled()); assertTrue(configuration.isAggressiveLazyLoading()); assertTrue(configuration.isMultipleResultSetsEnabled()); assertFalse(configuration.isUseGeneratedKeys()); assertTrue(configuration.isUseColumnLabel()); assertTrue(configuration.isCacheEnabled()); assertEquals(ExecutorType.SIMPLE, configuration.getDefaultExecutorType()); assertEquals(AutoMappingBehavior.PARTIAL, configuration.getAutoMappingBehavior()); assertFalse(configuration.isCallSettersOnNulls()); assertNull(configuration.getDefaultStatementTimeout()); assertFalse(configuration.isMapUnderscoreToCamelCase()); }
From source file:org.mybatis.guice.configuration.settings.DefaultExecutorTypeConfigurationSettingTest.java
License:Apache License
@Test public void applyConfigurationSetting_Simple() { DefaultExecutorTypeConfigurationSetting setting = new DefaultExecutorTypeConfigurationSetting( ExecutorType.SIMPLE); setting.applyConfigurationSetting(configuration); verify(configuration).setDefaultExecutorType(ExecutorType.SIMPLE); }