use of org.apache.ibatis.session.SqlSessionFactoryBuilder in project mybatis-3 by mybatis.
the class AutodiscoverTest method setup.
@BeforeClass
public static void setup() throws Exception {
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/autodiscover/MapperConfig.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
}
use of org.apache.ibatis.session.SqlSessionFactoryBuilder in project mybatis-3 by mybatis.
the class AwfulTableTest method setUp.
@Before
public void setUp() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:attest", "sa", "");
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/awful_table/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/awful_table/MapperConfig.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
}
use of org.apache.ibatis.session.SqlSessionFactoryBuilder in project mybatis-3 by mybatis.
the class XmlExternalRefTest method testMappedStatementCache.
@Test
public void testMappedStatementCache() throws Exception {
Reader configReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MapperConfig.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.PetMapper.select");
MappedStatement selectPersonStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.PersonMapper.select");
Cache cache = selectPetStatement.getCache();
assertEquals("org.apache.ibatis.submitted.xml_external_ref.PetMapper", cache.getId());
assertSame(cache, selectPersonStatement.getCache());
}
use of org.apache.ibatis.session.SqlSessionFactoryBuilder in project mybatis-3 by mybatis.
the class XmlExternalRefTest 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(PersonMapper.class);
configuration.addMapper(PetMapper.class);
return new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.session.SqlSessionFactoryBuilder in project mybatis-3 by mybatis.
the class XmlExternalRefTest method getSqlSessionFactoryXmlConfig.
private SqlSessionFactory getSqlSessionFactoryXmlConfig() throws Exception {
Reader configReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MapperConfig.xml");
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
configReader.close();
Connection conn = sqlSessionFactory.getConfiguration().getEnvironment().getDataSource().getConnection();
initDb(conn);
return sqlSessionFactory;
}
Aggregations