當前位置: 首頁>>代碼示例>>Java>>正文


Java SqlSessionFactoryBean.setDatabaseIdProvider方法代碼示例

本文整理匯總了Java中org.mybatis.spring.SqlSessionFactoryBean.setDatabaseIdProvider方法的典型用法代碼示例。如果您正苦於以下問題:Java SqlSessionFactoryBean.setDatabaseIdProvider方法的具體用法?Java SqlSessionFactoryBean.setDatabaseIdProvider怎麽用?Java SqlSessionFactoryBean.setDatabaseIdProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mybatis.spring.SqlSessionFactoryBean的用法示例。


在下文中一共展示了SqlSessionFactoryBean.setDatabaseIdProvider方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: historySqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public static SqlSessionFactoryBean historySqlSessionFactory(DataSource historyDataSource) throws Exception {
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(historyDataSource);
  sessionFactory.setTypeHandlersPackage("cern.c2mon.server.history.mapper");

  VendorDatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
  Properties properties = new Properties();
  properties.putAll(ImmutableMap.of(
      "HSQL", "oracle",
      "Oracle", "oracle",
      "MySQL", "mysql"
  ));
  databaseIdProvider.setProperties(properties);

  sessionFactory.setDatabaseIdProvider(databaseIdProvider);
  return sessionFactory;
}
 
開發者ID:c2mon,項目名稱:c2mon,代碼行數:19,代碼來源:HistoryDataSourceConfig.java

示例2: testAddToConfigTrue

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Test
public void testAddToConfigTrue() throws Exception {
  // the default SqlSessionFactory in AbstractMyBatisSpringTest is created with an explicitly set
  // MapperLocations list, so create a new factory here that tests auto-loading the config
  SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
  factoryBean.setDatabaseIdProvider(null);
  // mapperLocations properties defaults to null
  factoryBean.setDataSource(dataSource);
  factoryBean.setPlugins(new Interceptor[] { executorInterceptor });

  SqlSessionFactory sqlSessionFactory = factoryBean.getObject();

  find(new SqlSessionTemplate(sqlSessionFactory), true);
  assertCommit(); // SqlSesssionTemplate autocommits
  assertSingleConnection();
  assertExecuteCount(1);
}
 
開發者ID:lindzh,項目名稱:mybatis-spring-1.2.2,代碼行數:18,代碼來源:MapperFactoryBeanTest.java

示例3: configSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public static SqlSessionFactoryBean configSqlSessionFactory(DataSource configurationDataSource,
                                                            VendorDatabaseIdProvider databaseIdProvider) throws Exception {
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(configurationDataSource);
  sessionFactory.setTypeHandlersPackage("cern.c2mon.server.configuration.mybatis");
  sessionFactory.setDatabaseIdProvider(databaseIdProvider);
  return sessionFactory;
}
 
開發者ID:c2mon,項目名稱:c2mon,代碼行數:10,代碼來源:ConfigDataSourceConfig.java

示例4: cacheSqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public static SqlSessionFactoryBean cacheSqlSessionFactory(DataSource cacheDataSource) throws Exception {
  SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
  sessionFactory.setDataSource(cacheDataSource);
  sessionFactory.setDatabaseIdProvider(databaseIdProvider());
  sessionFactory.setTypeHandlersPackage("cern.c2mon.server.cache.dbaccess.type");
  return sessionFactory;
}
 
開發者ID:c2mon,項目名稱:c2mon,代碼行數:9,代碼來源:CacheDataSourceConfig.java

示例5: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
/**
 * 定義sqlSessionFactory的bean
 *
 * @param dataSource
 * @return
 * @throws Exception
 */
@Bean(name = "sqlSessionFactory")
@ConditionalOnMissingBean
//不允許特定的bean出現來跳過配置
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
	SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
	sqlSessionFactoryBean.setDataSource(dataSource);
	sqlSessionFactoryBean.setVfs(SpringBootVFS.class);
	if (StringUtils.hasText(this.properties.getConfigLocation())) {
		sqlSessionFactoryBean.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
	}

	sqlSessionFactoryBean.setConfiguration(properties.getConfiguration());
	if (!ObjectUtils.isEmpty(this.interceptors)) {
		sqlSessionFactoryBean.setPlugins(this.interceptors);
	}
	if (this.databaseIdProvider != null) {
		sqlSessionFactoryBean.setDatabaseIdProvider(this.databaseIdProvider);
	}
	if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
		sqlSessionFactoryBean.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
	}
	if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
		sqlSessionFactoryBean.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
	}
	if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
		sqlSessionFactoryBean.setMapperLocations(this.properties.resolveMapperLocations());
	}
	sqlSessionFactoryBean.setMybatisRefreshProperties(mybatisRefreshProperties);
	return sqlSessionFactoryBean.getObject();
}
 
開發者ID:whatlookingfor,項目名稱:spring-boot-sample,代碼行數:38,代碼來源:MybatisConfig.java

示例6: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
  SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
  factory.setDataSource(dataSource);
  factory.setVfs(SpringBootVFS.class);
  if (StringUtils.hasText(this.properties.getConfigLocation())) {
    factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
  }
  Configuration configuration = this.properties.getConfiguration();
  if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {
    configuration = new Configuration();
  }
  if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) {
    for (ConfigurationCustomizer customizer : this.configurationCustomizers) {
      customizer.customize(configuration);
    }
  }
  factory.setConfiguration(configuration);
  if (this.properties.getConfigurationProperties() != null) {
    factory.setConfigurationProperties(this.properties.getConfigurationProperties());
  }
  if (!ObjectUtils.isEmpty(this.interceptors)) {
    factory.setPlugins(this.interceptors);
  }
  if (this.databaseIdProvider != null) {
    factory.setDatabaseIdProvider(this.databaseIdProvider);
  }
  if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
    factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
  }
  if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
    factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
  }
  if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
    factory.setMapperLocations(this.properties.resolveMapperLocations());
  }

  return factory.getObject();
}
 
開發者ID:mybatis,項目名稱:spring-boot-starter,代碼行數:41,代碼來源:MybatisAutoConfiguration.java

示例7: sqlSessionFactory

import org.mybatis.spring.SqlSessionFactoryBean; //導入方法依賴的package包/類
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory() throws Exception {
    SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
    factory.setDataSource(dataSource());
    factory.setDatabaseIdProvider(new VendorDatabaseIdProvider());
    if (StringUtils.hasText(this.mybatisResolver.getProperty("config"))) {
        factory.setConfigLocation(
                this.resourceLoader.getResource(this.mybatisResolver.getProperty("config")));
    }
    return factory.getObject();
}
 
開發者ID:cnmydida,項目名稱:pandapay,代碼行數:13,代碼來源:DataBaseConfiguration.java


注:本文中的org.mybatis.spring.SqlSessionFactoryBean.setDatabaseIdProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。