本文整理汇总了Java中org.apache.ibatis.io.Resources.getResourceAsReader方法的典型用法代码示例。如果您正苦于以下问题:Java Resources.getResourceAsReader方法的具体用法?Java Resources.getResourceAsReader怎么用?Java Resources.getResourceAsReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.io.Resources
的用法示例。
在下文中一共展示了Resources.getResourceAsReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
System.out.println("Starting up CmsCmProcessor tests");
String resource = "mybatis-config.xml";
Reader reader = Resources.getResourceAsReader( resource );
SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(reader);
session = sf.openSession();
clazzMapper = session.getMapper(ClazzMapper.class);
ciMapper = session.getMapper(CIMapper.class);
mdValidator = new CmsMdValidator();
cmValidator = new CmsCmValidator();
mdProcessor = new CmsMdProcessor();
mdProcessor.setClazzMapper( clazzMapper );
mdProcessor.setMdValidator(mdValidator);
cmProcessor = new CmsCmProcessor();
cmProcessor.setCiMapper(ciMapper);
cmProcessor.setMdProcessor(mdProcessor);
cmProcessor.setCmValidator(cmValidator);
RelationMapper relationMapper=session.getMapper(RelationMapper.class);
mdProcessor.setRelationMapper(relationMapper);
}
示例2: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
// create an SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/maptypehandler/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/maptypehandler/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
示例3: initSqlSessionFactory
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void initSqlSessionFactory() throws Exception {
Connection conn = null;
try {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:mem:heavy_initial_load", "sa", "");
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/heavy_initial_load/ibatisConfig.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
} finally {
if (conn != null) {
conn.close();
}
}
}
示例4: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
// create an SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/array_result_type/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/array_result_type/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
示例5: initDatabase
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void initDatabase() throws Exception {
Connection conn = null;
try {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:mem:order_prefix_removed", "sa", "");
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/order_prefix_removed/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
runner.runScript(reader);
conn.commit();
reader.close();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/order_prefix_removed/ibatisConfig.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
} finally {
if (conn != null) {
conn.close();
}
}
}
示例6: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader(XML);
try {
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
} finally {
reader.close();
}
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
try {
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader(SQL);
try {
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
} finally {
reader.close();
}
} finally {
session.close();
}
}
示例7: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/inheritance/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/inheritance/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
示例8: testRefCursor1
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testRefCursor1() throws IOException {
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/refcursor/MapperConfig.xml");
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
OrdersMapper mapper = sqlSession.getMapper(OrdersMapper.class);
Map<String, Object> parameter = new HashMap<String, Object>();
parameter.put("orderId", 1);
mapper.getOrder1(parameter);
assertNotNull(parameter.get("order"));
List<Order> orders = (List<Order>) parameter.get("order");
assertEquals(1, orders.size());
Order order = orders.get(0);
assertEquals(3, order.getDetailLines().size());
} finally {
sqlSession.close();
}
}
示例9: openSession
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
/**
* Create a session with the specified configuration and initialized the database.
*/
private void openSession(String aConfig) throws Exception {
final String resource = "org/apache/ibatis/submitted/automatic_lazy_loading/ibatis-automatic-lazy-load-" + aConfig + ".xml";
Reader batisConfigReader = Resources.getResourceAsReader(resource);
SqlSessionFactory sqlSessionFactory;
try {
sqlSessionFactory = new SqlSessionFactoryBuilder().build(batisConfigReader);
} catch(Exception anException) {
throw new RuntimeException("Mapper configuration failed, expected this to work: " + anException.getMessage(), anException);
}
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
Reader createScriptReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/automatic_lazy_loading/create.sql");
runner.runScript(createScriptReader);
sqlSession = sqlSessionFactory.openSession();
}
示例10: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
Connection conn = null;
try {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:mem:parent_reference_3level", "sa", "");
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parent_reference_3level/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
runner.runScript(reader);
conn.commit();
reader.close();
reader = Resources.getResourceAsReader(getConfigPath());
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
} finally {
if (conn != null) {
conn.close();
}
}
}
示例11: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
Connection conn = null;
try {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:mem:parametrizedlist", "sa", "");
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parametrizedlist/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.setErrorLogWriter(new PrintWriter(System.err));
runner.runScript(reader);
conn.commit();
reader.close();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parametrizedlist/Config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
} finally {
if (conn != null) {
conn.close();
}
}
}
示例12: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parent_childs/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/parent_childs/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
示例13: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandlerinjection/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().register(handler);
sqlSessionFactory.getConfiguration().addMapper(Mapper.class);
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandlerinjection/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
示例14: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandler/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().register(StringTrimmingTypeHandler.class);
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandler/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
示例15: setUp
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/rounding/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/rounding/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}