use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class SqlProviderTest method methodNotFound.
@Test
public void methodNotFound() throws NoSuchMethodException {
expectedException.expect(BuilderException.class);
expectedException.expectMessage(is("Error creating SqlSource for SqlProvider. Method 'methodNotFound' not found in SqlProvider 'org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder'."));
new ProviderSqlSource(new Configuration(), ErrorMapper.class.getMethod("methodNotFound").getAnnotation(SelectProvider.class));
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class MultipleCrossIncludeTest method getSqlSessionFactoryJavaConfig.
private SqlSessionFactory getSqlSessionFactoryJavaConfig() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:xmlextref", "sa", "");
initDb(c);
Configuration configuration = new Configuration();
Environment environment = new Environment("development", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:xmlextref", null));
configuration.setEnvironment(environment);
configuration.addMapper(MultipleCrossIncludePersonMapper.class);
configuration.addMapper(MultipleCrossIncludePetMapper.class);
return new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class MultipleCrossIncludeTest method testMappedStatementCache.
@Test
public void testMappedStatementCache() throws Exception {
Reader configReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MultipleCrossIncludeMapperConfig.xml");
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
configReader.close();
Configuration configuration = sqlSessionFactory.getConfiguration();
configuration.getMappedStatementNames();
MappedStatement selectPetStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePetMapper.select");
MappedStatement selectPersonStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePersonMapper.select");
Cache cache = selectPetStatement.getCache();
assertEquals("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePetMapper", cache.getId());
assertSame(cache, selectPersonStatement.getCache());
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class MultipleIncludeTest method getSqlSessionFactoryJavaConfig.
private SqlSessionFactory getSqlSessionFactoryJavaConfig() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:xmlextref", "sa", "");
initDb(c);
Configuration configuration = new Configuration();
Environment environment = new Environment("development", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:xmlextref", null));
configuration.setEnvironment(environment);
configuration.addMapper(MultipleIncludePersonMapper.class);
return new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class SubstitutionInAnnotsTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:annots", "sa", "");
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/substitution_in_annots/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(c);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
runner.runScript(reader);
c.commit();
reader.close();
Configuration configuration = new Configuration();
Environment environment = new Environment("test", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:annots", null));
configuration.setEnvironment(environment);
configuration.addMapper(SubstitutionInAnnotsMapper.class);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
Aggregations