本文整理汇总了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);
}