当前位置: 首页>>代码示例>>Java>>正文


Java LocalCacheScope类代码示例

本文整理汇总了Java中org.apache.ibatis.session.LocalCacheScope的典型用法代码示例。如果您正苦于以下问题:Java LocalCacheScope类的具体用法?Java LocalCacheScope怎么用?Java LocalCacheScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalCacheScope类属于org.apache.ibatis.session包,在下文中一共展示了LocalCacheScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(Properties props) throws Exception {
  configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
  configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
  configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
  configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
  configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
  configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
  configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
  configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
  configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
  configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
  configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
  configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
  configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
  configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
  configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
  configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
  configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
  configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
  configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
  configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
  configuration.setLogPrefix(props.getProperty("logPrefix"));
  configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
  configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:26,代码来源:XMLConfigBuilder.java

示例2: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(Properties props) throws Exception {
	configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
	configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
	configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
	configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
	configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
	configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
	configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
	configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
	configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
	configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
	configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
	configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
	configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
	configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
	configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
	configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
	configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
	configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
	configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
	configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
	configuration.setLogPrefix(props.getProperty("logPrefix"));
	configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
	configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:26,代码来源:XMLConfigBuilder.java

示例3: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(Properties props) throws Exception {
    configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
    configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
    configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
    configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
    configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
    configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false));
    configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
    configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
    configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
    configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
    configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
    configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
    configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
    configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
    configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
    configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
    configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
    configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
    configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
    configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
    configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true));
    configuration.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false));
    configuration.setLogPrefix(props.getProperty("logPrefix"));
    @SuppressWarnings("unchecked")
    Class<? extends Log> logImpl = (Class<? extends Log>) resolveClass(props.getProperty("logImpl"));
    configuration.setLogImpl(logImpl);
    configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:30,代码来源:MybatisXMLConfigBuilder.java

示例4: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(XNode context) throws Exception {
    if (context != null) {
        Properties props = context.getChildrenAsProperties();
        // Check that all settings are known to the configuration class
        MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
        for (Object key : props.keySet()) {
            if (!metaConfig.hasSetter(String.valueOf(key))) {
                throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
            }
        }
        configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
        configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
        configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
        configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
        configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
        configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
        configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
        configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
        configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
        configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
        configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
        configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
        configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
        configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
        configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
        configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
        configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
        configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
        configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
        configuration.setLogPrefix(props.getProperty("logPrefix"));
        configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:34,代码来源:HierarchicalXMLConfigBuilder.java

示例5: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(Properties props) throws Exception {
  configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
  configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
  configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
  configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
  configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
  configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
  configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
  configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
  configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
  configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
  configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
  configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
  configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
  configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
  configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
  configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
  configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
  configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
  configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
  configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
  configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true));
  configuration.setLogPrefix(props.getProperty("logPrefix"));
  @SuppressWarnings("unchecked")
  Class<? extends Log> logImpl = (Class<? extends Log>)resolveClass(props.getProperty("logImpl"));
  configuration.setLogImpl(logImpl);
  configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:29,代码来源:XMLConfigBuilder.java

示例6: query

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <E> List<E> query(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, CacheKey key, BoundSql boundSql) throws SQLException {
  ErrorContext.instance().resource(ms.getResource()).activity("executing a query").object(ms.getId());
  if (closed) {
    throw new ExecutorException("Executor was closed.");
  }
  if (queryStack == 0 && ms.isFlushCacheRequired()) {
    clearLocalCache();
  }
  List<E> list;
  try {
    queryStack++;
    list = resultHandler == null ? (List<E>) localCache.getObject(key) : null;
    if (list != null) {
      handleLocallyCachedOutputParameters(ms, key, parameter, boundSql);
    } else {
      list = queryFromDatabase(ms, parameter, rowBounds, resultHandler, key, boundSql);
    }
  } finally {
    queryStack--;
  }
  if (queryStack == 0) {
    for (DeferredLoad deferredLoad : deferredLoads) {
      deferredLoad.load();
    }
    // issue #601
    deferredLoads.clear();
    if (configuration.getLocalCacheScope() == LocalCacheScope.STATEMENT) {
      // issue #482
      clearLocalCache();
    }
  }
  return list;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:36,代码来源:BaseExecutor.java

示例7: testSelectShouldFlushLocalCacheIfFlushLocalCacheAtferEachStatementIsTrue

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
@Test
public void testSelectShouldFlushLocalCacheIfFlushLocalCacheAtferEachStatementIsTrue() throws SQLException {
  sqlSessionFactory.getConfiguration().setLocalCacheScope(LocalCacheScope.STATEMENT);
  SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE);
  try {
    PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);
    List<Person> people = personMapper.selectAllNoFlush();
    updateDatabase(sqlSession.getConnection());
    people = personMapper.selectAllFlush();
    assertEquals("Simone", people.get(0).getFirstName());
    sqlSession.commit();
  } finally {
    sqlSession.close();
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:16,代码来源:ForceFlushOnSelectTest.java

示例8: shouldSuccessfullyLoadMinimalXMLConfigFile

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
@Test
public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertNotNull(config);
  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.PARTIAL));
  assertThat(config.getAutoMappingUnknownColumnBehavior(), is(AutoMappingUnknownColumnBehavior.NONE));
  assertThat(config.isCacheEnabled(), is(true));
  assertThat(config.getProxyFactory(), is(instanceOf(JavassistProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(false));
  assertThat(config.isAggressiveLazyLoading(), is(true));
  assertThat(config.isMultipleResultSetsEnabled(), is(true));
  assertThat(config.isUseColumnLabel(), is(true));
  assertThat(config.isUseGeneratedKeys(), is(false));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.SIMPLE));
  assertNull(config.getDefaultStatementTimeout());
  assertNull(config.getDefaultFetchSize());
  assertThat(config.isMapUnderscoreToCamelCase(), is(false));
  assertThat(config.isSafeRowBoundsEnabled(), is(false));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.SESSION));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.OTHER));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(true));
    assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(XMLLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(false));
  assertNull(config.getLogPrefix());
  assertNull(config.getLogImpl());
  assertNull(config.getConfigurationFactory());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:32,代码来源:XmlConfigBuilderTest.java

示例9: shouldSuccessfullyLoadXMLConfigFile

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
@Test
public void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/CustomizedSettingsMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();

  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.NONE));
  assertThat(config.getAutoMappingUnknownColumnBehavior(), is(AutoMappingUnknownColumnBehavior.WARNING));
  assertThat(config.isCacheEnabled(), is(false));
  assertThat(config.getProxyFactory(), is(instanceOf(CglibProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(true));
  assertThat(config.isAggressiveLazyLoading(), is(false));
  assertThat(config.isMultipleResultSetsEnabled(), is(false));
  assertThat(config.isUseColumnLabel(), is(false));
  assertThat(config.isUseGeneratedKeys(), is(true));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.BATCH));
  assertThat(config.getDefaultStatementTimeout(), is(10));
  assertThat(config.getDefaultFetchSize(), is(100));
  assertThat(config.isMapUnderscoreToCamelCase(), is(true));
  assertThat(config.isSafeRowBoundsEnabled(), is(true));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.STATEMENT));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.NULL));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(false));
  assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(RawLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(true));
  assertThat(config.getLogPrefix(), is("mybatis_"));
  assertThat(config.getLogImpl().getName(), is(Slf4jImpl.class.getName()));
  assertThat(config.getVfsImpl().getName(), is(JBoss6VFS.class.getName()));
  assertThat(config.getConfigurationFactory().getName(), is(String.class.getName()));

}
 
开发者ID:txazo,项目名称:mybatis,代码行数:34,代码来源:XmlConfigBuilderTest.java

示例10: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(XNode context) throws Exception {
  if (context != null) {
    Properties props = context.getChildrenAsProperties();
    // Check that all settings are known to the configuration class
    MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
    for (Object key : props.keySet()) {
      if (!metaConfig.hasSetter(String.valueOf(key))) {
        throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
      }
    }
    configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
    configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
    configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
    configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
    configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
    configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
    configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
    configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
    configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
    configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
    configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
    configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
    configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
    configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
    configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
    configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
    configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
    configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
    configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
    configuration.setLogPrefix(props.getProperty("logPrefix"));
    configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
    configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
  }
}
 
开发者ID:toulezu,项目名称:play,代码行数:35,代码来源:XMLConfigBuilder.java

示例11: query

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <E> List<E> query(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, CacheKey key, BoundSql boundSql) throws SQLException {
  ErrorContext.instance().resource(ms.getResource()).activity("executing a query").object(ms.getId());
  if (closed) {
    throw new ExecutorException("Executor was closed.");
  }
  if (queryStack == 0 && ms.isFlushCacheRequired()) {
    //清除本地缓存数据,回话缓存还可用
    clearLocalCache();
  }
  List<E> list;
  try {
    queryStack++;
    list = resultHandler == null ? (List<E>) localCache.getObject(key) : null;
    if (list != null) {
  	 //从本地缓存(一级缓存)中读取数据(当服务器宕机后数据消失)
      handleLocallyCachedOutputParameters(ms, key, parameter, boundSql);
    } else {
  	//3.缓存中没有值,直接从数据库中读取数据
      list = queryFromDatabase(ms, parameter, rowBounds, resultHandler, key, boundSql);
    }
  } finally {
    queryStack--;
  }
  if (queryStack == 0) {
    for (DeferredLoad deferredLoad : deferredLoads) {
      deferredLoad.load();
    }
    // issue #601
    deferredLoads.clear();
    if (configuration.getLocalCacheScope() == LocalCacheScope.STATEMENT) {
      // issue #482
      clearLocalCache();
    }
  }
  return list;
}
 
开发者ID:toulezu,项目名称:play,代码行数:39,代码来源:BaseExecutor.java

示例12: shouldSuccessfullyLoadMinimalXMLConfigFile

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
@Test
public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertNotNull(config);
  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.PARTIAL));
  assertThat(config.isCacheEnabled(), is(true));
  assertThat(config.getProxyFactory(), is(instanceOf(JavassistProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(false));
  assertThat(config.isAggressiveLazyLoading(), is(true));
  assertThat(config.isMultipleResultSetsEnabled(), is(true));
  assertThat(config.isUseColumnLabel(), is(true));
  assertThat(config.isUseGeneratedKeys(), is(false));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.SIMPLE));
  assertNull(config.getDefaultStatementTimeout());
  assertNull(config.getDefaultFetchSize());
  assertThat(config.isMapUnderscoreToCamelCase(), is(false));
  assertThat(config.isSafeRowBoundsEnabled(), is(false));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.SESSION));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.OTHER));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(true));
    assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(XMLLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(false));
  assertNull(config.getLogPrefix());
  assertNull(config.getLogImpl());
  assertNull(config.getConfigurationFactory());
}
 
开发者ID:toulezu,项目名称:play,代码行数:31,代码来源:XmlConfigBuilderTest.java

示例13: shouldSuccessfullyLoadXMLConfigFile

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
@Test
public void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/CustomizedSettingsMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();

  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.NONE));
  assertThat(config.isCacheEnabled(), is(false));
  assertThat(config.getProxyFactory(), is(instanceOf(CglibProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(true));
  assertThat(config.isAggressiveLazyLoading(), is(false));
  assertThat(config.isMultipleResultSetsEnabled(), is(false));
  assertThat(config.isUseColumnLabel(), is(false));
  assertThat(config.isUseGeneratedKeys(), is(true));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.BATCH));
  assertThat(config.getDefaultStatementTimeout(), is(10));
  assertThat(config.getDefaultFetchSize(), is(100));
  assertThat(config.isMapUnderscoreToCamelCase(), is(true));
  assertThat(config.isSafeRowBoundsEnabled(), is(true));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.STATEMENT));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.NULL));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(false));
  assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(RawLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(true));
  assertThat(config.getLogPrefix(), is("mybatis_"));
  assertThat(config.getLogImpl().getName(), is(Slf4jImpl.class.getName()));
  assertThat(config.getConfigurationFactory().getName(), is(String.class.getName()));

}
 
开发者ID:toulezu,项目名称:play,代码行数:32,代码来源:XmlConfigBuilderTest.java

示例14: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(XNode context) throws Exception {
  if (context != null) {
    Properties props = context.getChildrenAsProperties();
    // Check that all settings are known to the configuration class
    MetaClass metaConfig = MetaClass.forClass(Configuration.class);
    for (Object key : props.keySet()) {
      if (!metaConfig.hasSetter(String.valueOf(key))) {
        throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
      }
    }
    configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
    configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
    configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
    configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
    configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
    configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
    configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
    configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
    configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
    configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
    configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
    configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
    configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
    configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
    configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
    configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
    configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
    configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
    configuration.setLogPrefix(props.getProperty("logPrefix"));
    configuration.setLogImpl(resolveClass(props.getProperty("logImpl")));
    configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
  }
}
 
开发者ID:chanedi,项目名称:QuickProject,代码行数:34,代码来源:XMLConfigBuilder.java

示例15: settingsElement

import org.apache.ibatis.session.LocalCacheScope; //导入依赖的package包/类
private void settingsElement(Properties props) throws Exception {
  configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
  configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
  configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
  configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
  configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
  configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false));
  configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
  configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
  configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
  configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
  configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
  configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
  configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
  configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
  configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
  configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
  configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
  configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
  configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
  @SuppressWarnings("unchecked")
  Class<? extends TypeHandler> typeHandler = (Class<? extends TypeHandler>)resolveClass(props.getProperty("defaultEnumTypeHandler"));
  configuration.setDefaultEnumTypeHandler(typeHandler);
  configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
  configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true));
  configuration.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false));
  configuration.setLogPrefix(props.getProperty("logPrefix"));
  @SuppressWarnings("unchecked")
  Class<? extends Log> logImpl = (Class<? extends Log>)resolveClass(props.getProperty("logImpl"));
  configuration.setLogImpl(logImpl);
  configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:33,代码来源:XMLConfigBuilder.java


注:本文中的org.apache.ibatis.session.LocalCacheScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。