本文整理匯總了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();
}
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}