use of org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory in project mybatis-3 by mybatis.
the class ReverseIncludeTest 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(ReverseIncludePersonMapper.class);
return new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory in project mybatis-3 by mybatis.
the class SameIdTest 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(SameIdPersonMapper.class);
configuration.addMapper(SameIdPetMapper.class);
return new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory in project mybatis-3 by mybatis.
the class AutoMappingUnknownColumnBehaviorTest method setup.
@BeforeClass
public static void setup() throws Exception {
DataSource dataSource = BaseDataTest.createBlogDataSource();
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("Production", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
configuration.addMapper(Mapper.class);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory in project mybatis-3 by mybatis.
the class ManyAnnoTest method testGetMessageForEmptyDatabase.
@Test
public void testGetMessageForEmptyDatabase() throws Exception {
final Environment environment = new Environment("test", new JdbcTransactionFactory(), BaseDataTest.createBlogDataSource());
final Configuration config = new Configuration(environment);
config.addMapper(PostMapper.class);
final SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(config);
final SqlSession session = factory.openSession();
PostMapper mapper = session.getMapper(PostMapper.class);
List<AnnoPost> posts = mapper.getPosts(101);
assertEquals(3, posts.size());
assertEquals(3, posts.get(0).getTags().size());
assertEquals(1, posts.get(1).getTags().size());
assertEquals(0, posts.get(2).getTags().size());
session.close();
}
use of org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory in project mybatis-3 by mybatis.
the class NpeExtendsTest method getSqlSessionFactoryWithConstructor.
private SqlSessionFactory getSqlSessionFactoryWithConstructor() {
UnpooledDataSourceFactory unpooledDataSourceFactory = new UnpooledDataSourceFactory();
Properties properties = new Properties();
properties.setProperty("driver", "org.hsqldb.jdbcDriver");
properties.setProperty("url", "jdbc:hsqldb:mem:extends_with_constructor");
properties.setProperty("username", "sa");
unpooledDataSourceFactory.setProperties(properties);
Environment environment = new Environment("extends_with_constructor", new JdbcTransactionFactory(), unpooledDataSourceFactory.getDataSource());
Configuration configuration = new Configuration();
configuration.setEnvironment(environment);
configuration.addMapper(StudentConstructorMapper.class);
configuration.addMapper(TeacherMapper.class);
configuration.getMappedStatementNames();
configuration.setAutoMappingBehavior(AutoMappingBehavior.NONE);
return new DefaultSqlSessionFactory(configuration);
}
Aggregations