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


Java SqlSessionFactoryBuilder.build方法代碼示例

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


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

示例1: shouldDemonstrateDuplicateResourceIssue

import org.apache.ibatis.session.SqlSessionFactoryBuilder; //導入方法依賴的package包/類
@Test
public void shouldDemonstrateDuplicateResourceIssue() throws Exception {
  final String resource = "org/apache/ibatis/submitted/duplicate_resource_loaded/Config.xml";
  final Reader reader = Resources.getResourceAsReader(resource);
  final SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
  final SqlSessionFactory factory = builder.build(reader);
  final SqlSession sqlSession = factory.openSession();
  try {
    final Mapper mapper = sqlSession.getMapper(Mapper.class);
    final List<Map<String, Object>> list = mapper.selectAllBlogs();
    Assert.assertEquals(2,list.size());
  } finally {
    sqlSession.close();
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:16,代碼來源:DuplicateResourceTest.java

示例2: init

import org.apache.ibatis.session.SqlSessionFactoryBuilder; //導入方法依賴的package包/類
/**
 * 初始化鏈接mariadb
 * 
 * @param configDir
 *            地址
 * @param configName
 *            配置文件名
 * @param log
 *            日誌可為null
 * @throws Exception
 */
public static void init(String configDir, String configName, ILog log) throws Exception {
	if (configDir == null || configDir.equals("")) {
		throw new Exception("配置文件信息為空");
	}
	MybatisManager.log = log;
	if (!configDir.endsWith("/") && !configDir.endsWith("\\")) {
		configDir += "/";
	}
	String xmlPath = configDir + configName;
	InputStream inputStream = new FileInputStream(xmlPath);
	SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
	sqlSessionFactory = builder.build(inputStream);
}
 
開發者ID:dianbaer,項目名稱:grain,代碼行數:25,代碼來源:MybatisManager.java

示例3: testExternalRefAfterSelectKey

import org.apache.ibatis.session.SqlSessionFactoryBuilder; //導入方法依賴的package包/類
@Test
public void testExternalRefAfterSelectKey() throws Exception {
  String resource = "org/apache/ibatis/submitted/refid_resolution/ExternalMapperConfig.xml";
  Reader reader = Resources.getResourceAsReader(resource);
  SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
  SqlSessionFactory sqlSessionFactory = builder.build(reader);
  reader.close();
  sqlSessionFactory.getConfiguration().getMappedStatementNames();
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:10,代碼來源:ExternalRefidResolutionTest.java

示例4: testIncludes

import org.apache.ibatis.session.SqlSessionFactoryBuilder; //導入方法依賴的package包/類
@Test(expected = PersistenceException.class)
public void testIncludes() throws Exception {
  String resource = "org/apache/ibatis/submitted/refid_resolution/MapperConfig.xml";
  Reader reader = Resources.getResourceAsReader(resource);
  SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
  SqlSessionFactory sqlSessionFactory = builder.build(reader);
  sqlSessionFactory.getConfiguration().getMappedStatementNames();
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:9,代碼來源:RefidResolutionTest.java

示例5: testSelectKey

import org.apache.ibatis.session.SqlSessionFactoryBuilder; //導入方法依賴的package包/類
@Test
public void testSelectKey() throws Exception {
  // this test checks to make sure that we can have select keys with the same
  // insert id in different namespaces
  String resource = "org/apache/ibatis/submitted/selectkey/MapperConfig.xml";
  Reader reader = Resources.getResourceAsReader(resource);
  SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
  SqlSessionFactory sqlMapper = builder.build(reader);
  assertNotNull(sqlMapper);
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:11,代碼來源:SelectKeyTest.java

示例6: shouldParseMapWithIntegerJdbcType

import org.apache.ibatis.session.SqlSessionFactoryBuilder; //導入方法依賴的package包/類
@Test
public void shouldParseMapWithIntegerJdbcType() throws Exception {
  String resource = "org/apache/ibatis/submitted/integer_enum/MapperConfig.xml";
  Reader reader = Resources.getResourceAsReader(resource);
  SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
  builder.build(reader);
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:8,代碼來源:IntegerEnumTest.java


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