org.apache.ibatis.session.Configuration.setMapUnderscoreToCamelCase()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(21.9k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.apache.ibatis.session.Configuration.setMapUnderscoreToCamelCase()方法的一些代码示例,展示了Configuration.setMapUnderscoreToCamelCase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.setMapUnderscoreToCamelCase()方法的具体详情如下:
包路径:org.apache.ibatis.session.Configuration
类名称:Configuration
方法名:setMapUnderscoreToCamelCase

Configuration.setMapUnderscoreToCamelCase介绍

暂无

代码示例

代码示例来源:origin: 527515025/springBoot

@Bean(name = "sqlSessionFactory")
public SqlSessionFactoryBean sqlSessionFactory(
    ApplicationContext applicationContext) throws Exception {
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(dataSource);
  org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
  configuration.setMapUnderscoreToCamelCase(true);
  configuration.setJdbcTypeForNull(JdbcType.NULL);
  sessionFactory.setMapperLocations(applicationContext.getResources("classpath:mapper/*.xml"));
  return sessionFactory;
}

代码示例来源:origin: baomidou/mybatis-plus

private void settingsElement(Properties props) {
  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.setDefaultEnumTypeHandler(resolveClass(props.getProperty("defaultEnumTypeHandler")));
  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"));
  configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}

代码示例来源:origin: 527515025/springBoot

@Bean(name = "sqlSessionFactory")
  public SqlSessionFactoryBean sqlSessionFactory(
      ApplicationContext applicationContext) throws Exception {
    SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
    sessionFactory.setDataSource(dataSource);

    org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
    configuration.setMapUnderscoreToCamelCase(true);
    configuration.setJdbcTypeForNull(JdbcType.NULL);
    configuration.setLogImpl(org.apache.ibatis.logging.log4j.Log4jImpl.class);//use log4j log
    sessionFactory.setConfiguration(configuration);
    sessionFactory.setMapperLocations(applicationContext.getResources("classpath:com/yy/example/mapper/*.xml"));
//
//        Properties prop = new Properties();
//        prop.setProperty("supportMethodsArguments","true");
//        prop.setProperty("rowBoundsWithCount", "true");
//        prop.setProperty("params","pageNum=pageNum;pageSize=pageSize;");
//        PageInterceptor pi = new PageInterceptor();
//        pi.setProperties(prop);
//        sessionFactory.setPlugins(new Interceptor[]{pi});

    return sessionFactory;
  }

代码示例来源:origin: camunda/camunda-bpm-platform

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")));
}

代码示例来源:origin: org.mybatis/mybatis

private void settingsElement(Properties props) {
 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.setDefaultEnumTypeHandler(resolveClass(props.getProperty("defaultEnumTypeHandler")));
 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"));
 configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}

代码示例来源:origin: lxy-go/SpringBoot

@Override
  public void customize(Configuration configuration) {
    configuration.setMapUnderscoreToCamelCase(true);
  }
};

代码示例来源:origin: cuzz1/springboot-learning

@Bean
  public ConfigurationCustomizer configurationCustomizer() {
    return configuration -> configuration.setMapUnderscoreToCamelCase(true);
  }
}

代码示例来源:origin: cyhbyw/springBoot_atguigu

@Bean
  public ConfigurationCustomizer configurationCustomizer() {
    return configuration -> configuration.setMapUnderscoreToCamelCase(true);
  }
}

代码示例来源:origin: luyunfeng/soulcoder

@Bean("sqlSessionFactorySoul")
public SqlSessionFactory sqlSessionFactorySoul() throws Exception {
  SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
  sqlSessionFactoryBean.setDataSource(druidDataSourceSoul);
  sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
  PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  sqlSessionFactoryBean.setMapperLocations(
      resolver.getResources("classpath*:mapper/**/*.xml"));
  SqlSessionFactory sqlSessionFactory = null;
  try {
    sqlSessionFactory = sqlSessionFactoryBean.getObject();
  } catch (Exception e) {
    e.printStackTrace();
    System.exit(0);
  }
  org.apache.ibatis.session.Configuration configuration = sqlSessionFactory.getConfiguration();
  configuration.setMapUnderscoreToCamelCase(true);
  return sqlSessionFactoryBean.getObject();
}

代码示例来源:origin: cmlbeliever/SpringBatch

@Bean(name = "readOnlySqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("readOnlyDataSource") DataSource readOnlyDataSource,
    @Qualifier("readOnlyConfiguration") MybatisConfigurationProperties readOnlyConfiguration) throws Exception {
  log.info("*************************sqlSessionFactory:begin***********************" + readOnlyConfiguration);
  VFS.addImplClass(SpringBootVFS.class);
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(readOnlyDataSource);
  sessionFactory.setTypeAliasesPackage(readOnlyConfiguration.typeAliasesPackage);
  sessionFactory.setTypeHandlersPackage(readOnlyConfiguration.typeHandlerPackage);
  
  org.apache.ibatis.session.Configuration configuration=new org.apache.ibatis.session.Configuration();
  configuration.setMapUnderscoreToCamelCase(true);
  sessionFactory.setConfiguration(configuration);
  ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  if (readOnlyConfiguration.mapperLocations.contains(",")) {
    List<Resource> resources = new ArrayList<>();
    for (String s : readOnlyConfiguration.mapperLocations.split(",")) {
      resources.addAll(Arrays.asList(resolver.getResources(s)));
    }
    sessionFactory.setMapperLocations(resources.toArray(new Resource[] {}));
  } else {
    sessionFactory.setMapperLocations(resolver.getResources(readOnlyConfiguration.mapperLocations));
  }
  // sessionFactory
  // .setConfigLocation(new
  // PathMatchingResourcePatternResolver().getResource(properties.configLocation));
  SqlSessionFactory resultSessionFactory = sessionFactory.getObject();
  log.info("*************************sqlSessionFactory:successs:" + resultSessionFactory + "***********************" + readOnlyConfiguration);
  return resultSessionFactory;
}

代码示例来源:origin: cmlbeliever/SpringBatch

@Primary
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(DataSource datasource, MybatisConfigurationProperties properties) throws Exception {
  log.info("*************************sqlSessionFactory:begin***********************" + properties);
  VFS.addImplClass(SpringBootVFS.class);
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(datasource);
  sessionFactory.setTypeAliasesPackage(properties.typeAliasesPackage);
  sessionFactory.setTypeHandlersPackage(properties.typeHandlerPackage);
  
  org.apache.ibatis.session.Configuration configuration=new org.apache.ibatis.session.Configuration();
  configuration.setMapUnderscoreToCamelCase(true);
  sessionFactory.setConfiguration(configuration);
  ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  if (properties.mapperLocations.contains(",")) {
    List<Resource> resources = new ArrayList<>();
    for (String s : properties.mapperLocations.split(",")) {
      resources.addAll(Arrays.asList(resolver.getResources(s)));
    }
    sessionFactory.setMapperLocations(resources.toArray(new Resource[] {}));
  } else {
    sessionFactory.setMapperLocations(resolver.getResources(properties.mapperLocations));
  }
  // sessionFactory
  // .setConfigLocation(new
  // PathMatchingResourcePatternResolver().getResource(properties.configLocation));
  SqlSessionFactory resultSessionFactory = sessionFactory.getObject();
  log.info("*************************sqlSessionFactory:successs:" + resultSessionFactory + "***********************" + properties);
  return resultSessionFactory;
}

代码示例来源:origin: com.gitee.sunlu/zm-cloud-dao

@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactoryBean() {
  SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
  bean.setDataSource(dataSource);
  bean.setTypeAliasesPackage("com.zm.business.model");
  //分页插件
  PageHelper pageHelper = new PageHelper();
  Properties properties = new Properties();
  properties.setProperty("reasonable", "true");
  properties.setProperty("supportMethodsArguments", "true");
  properties.setProperty("returnPageInfo", "check");
  properties.setProperty("params", "count=countSql");
  pageHelper.setProperties(properties);
  //添加插件
  bean.setPlugins(new Interceptor[]{pageHelper});
  //添加XML目录
  ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  try {
    bean.setMapperLocations(resolver.getResources("classpath*:mapper/*.xml"));
    // 设置过滤_
    org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
    configuration.setMapUnderscoreToCamelCase(true);
    bean.setConfiguration(configuration);
    
    return bean.getObject();
  } catch (Exception e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.lodsve/lodsve-mybatis

@Override
  public void customize(Configuration configuration) {
    configuration.setMapUnderscoreToCamelCase(mapUnderscoreToCamelCase);

    configuration.addInterceptor(new PaginationInterceptor());
    configuration.addInterceptor(new BaseRepositoryInterceptor());

    if (ArrayUtils.isNotEmpty(enumsLocations)) {
      TypeHandler<?>[] handlers = new TypeHandlerScanner().find(enumsLocations);
      Arrays.stream(handlers).forEach(configuration.getTypeHandlerRegistry()::register);
    }
  }
}

代码示例来源:origin: heibaiying/spring-samples-for-all

/***
   * 自定义会话工厂
   * @param dataSource 数据源
   * @return :自定义的会话工厂
   */
  private SqlSessionFactory createSqlSessionFactory(DataSource dataSource) throws Exception {
    SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION));
    // 其他可配置项(包括是否打印sql,是否开启驼峰命名等)
    org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
    configuration.setMapUnderscoreToCamelCase(true);
    configuration.setLogImpl(StdOutImpl.class);
    factoryBean.setConfiguration(configuration);
    /* *
     * 采用个如下方式配置属性的时候一定要保证已经进行数据源的配置(setDataSource)和数据源和MapperLocation配置(setMapperLocations)
     * factoryBean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
     * factoryBean.getObject().getConfiguration().setLogImpl(StdOutImpl.class);
     **/
    return factoryBean.getObject();
  }
}

代码示例来源:origin: com.minlia.cloud.thirdparty/spring-data-batis-starter

configuration.setMapUnderscoreToCamelCase(true);
if (null != properties.getDefaultScriptingLanguage()) {
  configuration.setDefaultScriptingLanguage(properties.getDefaultScriptingLanguage());

代码示例来源:origin: org.alfresco/alfresco-repository

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")));

代码示例来源:origin: deas/alfresco

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")));

代码示例来源:origin: Alfresco/alfresco-repository

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")));

代码示例来源:origin: chanedi/QuickProject

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")));

代码示例来源:origin: jneat/mybatis-types

static synchronized void setupSessionFactoryBuilder(DataSource ds) {
  TransactionFactory transactionFactory = new JdbcTransactionFactory();
  Environment environment = new Environment("jneat", transactionFactory, ds);
  Configuration configuration = new Configuration(environment);
  configuration.getTypeHandlerRegistry().register("com.github.jneat.mybatis");
  configuration.setMapUnderscoreToCamelCase(true);
  // Add Mappers
  configuration.addMapper(TypesMapper.class);
  configuration.addMapper(ArraysMapper.class);
  configuration.addMapper(TimeMapper.class);
  ssf = new SqlSessionFactoryBuilder().build(configuration);
}

相关文章

微信公众号

最新文章

更多

Configuration类方法