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