Search in sources :

Example 6 with TransactionFactory

use of org.apache.ibatis.transaction.TransactionFactory in project mybatis-3 by mybatis.

the class ClobReaderTypeHandlerTest method setupSqlSessionFactory.

@BeforeAll
static void setupSqlSessionFactory() throws Exception {
    DataSource dataSource = BaseDataTest.createUnpooledDataSource("org/apache/ibatis/type/jdbc.properties");
    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);
    BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(), "org/apache/ibatis/type/ClobReaderTypeHandlerTest.sql");
}
Also used : Configuration(org.apache.ibatis.session.Configuration) TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) DataSource(javax.sql.DataSource) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 7 with TransactionFactory

use of org.apache.ibatis.transaction.TransactionFactory in project mybatis-3 by mybatis.

the class FlushTest method setup.

@BeforeAll
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.setDefaultExecutorType(ExecutorType.BATCH);
    configuration.getTypeAliasRegistry().registerAlias(Post.class);
    configuration.getTypeAliasRegistry().registerAlias(Author.class);
    configuration.addMapper(BoundAuthorMapper.class);
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
Also used : TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) Environment(org.apache.ibatis.mapping.Environment) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) DataSource(javax.sql.DataSource) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with TransactionFactory

use of org.apache.ibatis.transaction.TransactionFactory in project mybatis-3 by mybatis.

the class MapperMethodParamTest method setup.

@BeforeAll
static void setup() throws Exception {
    DataSource dataSource = BaseDataTest.createUnpooledDataSource(BaseDataTest.BLOG_PROPERTIES);
    BaseDataTest.runScript(dataSource, "org/apache/ibatis/binding/paramtest-schema.sql");
    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);
}
Also used : Configuration(org.apache.ibatis.session.Configuration) TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) DataSource(javax.sql.DataSource) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 9 with TransactionFactory

use of org.apache.ibatis.transaction.TransactionFactory in project mapping-benchmark by arnaudroger.

the class SqlSessionFact method getSqlSessionFactory.

public static SqlSessionFactory getSqlSessionFactory(ConnectionParam connParam) {
    TransactionFactory transactionFactory = new JdbcTransactionFactory();
    Environment environment = new Environment("development", transactionFactory, connParam.dataSource);
    Configuration configuration = new Configuration(environment);
    configuration.addMapper(DbObjectMapper.class);
    SqlSessionFactory sqlSession = new SqlSessionFactoryBuilder().build(configuration);
    return sqlSession;
}
Also used : Configuration(org.apache.ibatis.session.Configuration) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) SqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory)

Example 10 with TransactionFactory

use of org.apache.ibatis.transaction.TransactionFactory in project mybatis-3 by mybatis.

the class BindingTest method setup.

@BeforeAll
static void setup() throws Exception {
    DataSource dataSource = BaseDataTest.createBlogDataSource();
    BaseDataTest.runScript(dataSource, BaseDataTest.BLOG_DDL);
    BaseDataTest.runScript(dataSource, BaseDataTest.BLOG_DATA);
    TransactionFactory transactionFactory = new JdbcTransactionFactory();
    Environment environment = new Environment("Production", transactionFactory, dataSource);
    Configuration configuration = new Configuration(environment);
    configuration.setLazyLoadingEnabled(true);
    // to test legacy style reference (#{0} #{1})
    configuration.setUseActualParamName(false);
    configuration.getTypeAliasRegistry().registerAlias(Blog.class);
    configuration.getTypeAliasRegistry().registerAlias(Post.class);
    configuration.getTypeAliasRegistry().registerAlias(Author.class);
    configuration.addMapper(BoundBlogMapper.class);
    configuration.addMapper(BoundAuthorMapper.class);
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
Also used : Configuration(org.apache.ibatis.session.Configuration) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) DataSource(javax.sql.DataSource) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

TransactionFactory (org.apache.ibatis.transaction.TransactionFactory)15 Environment (org.apache.ibatis.mapping.Environment)12 DataSource (javax.sql.DataSource)9 JdbcTransactionFactory (org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory)7 Configuration (org.apache.ibatis.session.Configuration)6 BeforeAll (org.junit.jupiter.api.BeforeAll)6 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)5 Transaction (org.apache.ibatis.transaction.Transaction)5 Properties (java.util.Properties)3 SQLException (java.sql.SQLException)2 BaseDataTest (org.apache.ibatis.BaseDataTest)2 Executor (org.apache.ibatis.executor.Executor)2 ManagedTransactionFactory (org.apache.ibatis.transaction.managed.ManagedTransactionFactory)2 Test (org.junit.jupiter.api.Test)2 BaseBuilder (org.apache.ibatis.builder.BaseBuilder)1 BuilderException (org.apache.ibatis.builder.BuilderException)1 DataSourceFactory (org.apache.ibatis.datasource.DataSourceFactory)1 ExecutorException (org.apache.ibatis.executor.ExecutorException)1 XNode (org.apache.ibatis.parsing.XNode)1 SqlSessionFactory (org.apache.ibatis.session.SqlSessionFactory)1