Java 类org.apache.ibatis.session.defaults.DefaultSqlSessionFactory 实例源码

项目:MybatisCode    文件:EnumWithOgnlTest.java   
@Test
public void testConfiguration() {
    UnpooledDataSourceFactory dataSourceFactory = new UnpooledDataSourceFactory();
    Properties dataSourceProperties = new Properties();
    dataSourceProperties.put("driver", "org.hsqldb.jdbcDriver");
    dataSourceProperties.put("url", "jdbc:hsqldb:mem:xml_references");
    dataSourceProperties.put("username", "sa");
    dataSourceFactory.setProperties(dataSourceProperties);
    Environment environment = new Environment("test", new JdbcTransactionFactory(), dataSourceFactory.getDataSource());
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.getTypeAliasRegistry().registerAlias(Person.class);
    configuration.addMapper(PersonMapper.class);
    configuration.addMapper(PersonMapper2.class);
    new DefaultSqlSessionFactory(configuration);
}
项目:MybatisCode    文件:NpeExtendsTest.java   
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);
}
项目:mybatis    文件:EnumWithOgnlTest.java   
@Test
public void testConfiguration() {
    UnpooledDataSourceFactory dataSourceFactory = new UnpooledDataSourceFactory();
    Properties dataSourceProperties = new Properties();
    dataSourceProperties.put("driver", "org.hsqldb.jdbcDriver");
    dataSourceProperties.put("url", "jdbc:hsqldb:mem:xml_references");
    dataSourceProperties.put("username", "sa");
    dataSourceFactory.setProperties(dataSourceProperties);
    Environment environment = new Environment("test", new JdbcTransactionFactory(), dataSourceFactory.getDataSource());
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.getTypeAliasRegistry().registerAlias(Person.class);
    configuration.addMapper(PersonMapper.class);
    configuration.addMapper(PersonMapper2.class);
    new DefaultSqlSessionFactory(configuration);
}
项目:mybatis    文件:NpeExtendsTest.java   
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);
}
项目:shardy    文件:ShardSqlSessionFactoryBean.java   
@Override
public SqlSessionFactory getObject() throws Exception {
    SqlSessionFactory sqlSessionFactory = super.getObject();
    if (sqlSessionFactory instanceof DefaultSqlSessionFactory)
        return proxy(sqlSessionFactory, methodInvocation -> {
            if (methodInvocation.getMethod().getName().equals("openSession")) {
                SqlSession session = (SqlSession) methodInvocation.proceed();
                if (session instanceof DefaultSqlSession) {
                    DefaultSqlSession defaultSqlSession = (DefaultSqlSession) session;
                    Executor executor = (Executor) ReflectionUtils.getFieldValue(defaultSqlSession, "executor");
                    if (executor instanceof CachingExecutor) {
                        CachingExecutor cachingExecutor = (CachingExecutor) executor;
                        SimpleExecutor ex = (SimpleExecutor) ReflectionUtils.getFieldValue(cachingExecutor, "delegate");
                        System.out.println("ex-> " + ex.getClass().getName());
                        ReflectionUtils.setDeclaredFieldValue(cachingExecutor, "delegate", proxy(ex, invocation -> {
                            System.out.println("method->" + invocation.getMethod());
                            return invocation.proceed();
                        }));
                    }
                }
                return session;
            }
            return methodInvocation.proceed();
        });
    return sqlSessionFactory;
}
项目:mybaties    文件:EnumWithOgnlTest.java   
@Test
public void testConfiguration() {
    UnpooledDataSourceFactory dataSourceFactory = new UnpooledDataSourceFactory();
    Properties dataSourceProperties = new Properties();
    dataSourceProperties.put("driver", "org.hsqldb.jdbcDriver");
    dataSourceProperties.put("url", "jdbc:hsqldb:mem:xml_references");
    dataSourceProperties.put("username", "sa");
    dataSourceFactory.setProperties(dataSourceProperties);
    Environment environment = new Environment("test", new JdbcTransactionFactory(), dataSourceFactory.getDataSource());
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.getTypeAliasRegistry().registerAlias(Person.class);
    configuration.addMapper(PersonMapper.class);
    configuration.addMapper(PersonMapper2.class);
    new DefaultSqlSessionFactory(configuration);
}
项目:mybaties    文件:NpeExtendsTest.java   
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);
}
项目:play    文件:EnumWithOgnlTest.java   
@Test
public void testConfiguration() {
    UnpooledDataSourceFactory dataSourceFactory = new UnpooledDataSourceFactory();
    Properties dataSourceProperties = new Properties();
    dataSourceProperties.put("driver", "org.hsqldb.jdbcDriver");
    dataSourceProperties.put("url", "jdbc:hsqldb:mem:xml_references");
    dataSourceProperties.put("username", "sa");
    dataSourceFactory.setProperties(dataSourceProperties);
    Environment environment = new Environment("test", new JdbcTransactionFactory(), dataSourceFactory.getDataSource());
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.getTypeAliasRegistry().registerAlias(Person.class);
    configuration.addMapper(PersonMapper.class);
    configuration.addMapper(PersonMapper2.class);
    new DefaultSqlSessionFactory(configuration);
}
项目:play    文件:NpeExtendsTest.java   
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);
}
项目:mybatis-3    文件:EnumWithOgnlTest.java   
@Test
public void testConfiguration() {
    UnpooledDataSourceFactory dataSourceFactory = new UnpooledDataSourceFactory();
    Properties dataSourceProperties = new Properties();
    dataSourceProperties.put("driver", "org.hsqldb.jdbcDriver");
    dataSourceProperties.put("url", "jdbc:hsqldb:mem:xml_references");
    dataSourceProperties.put("username", "sa");
    dataSourceFactory.setProperties(dataSourceProperties);
    Environment environment = new Environment("test", new JdbcTransactionFactory(), dataSourceFactory.getDataSource());
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.getTypeAliasRegistry().registerAlias(Person.class);
    configuration.addMapper(PersonMapper.class);
    configuration.addMapper(PersonMapper2.class);
    new DefaultSqlSessionFactory(configuration);
}
项目:mybatis-3    文件:NpeExtendsTest.java   
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);
}
项目:MybatisCode    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoResultHandlers() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithMultipleHandlers.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    DefaultResultHandler handler1 = new DefaultResultHandler();
    DefaultResultHandler handler2 = new DefaultResultHandler();
    AuthorMapperWithMultipleHandlers mapper = sqlSession.getMapper(AuthorMapperWithMultipleHandlers.class);
    mapper.selectAuthor(101, handler1, handler2);
  } finally {
    sqlSession.close();
  }
}
项目:MybatisCode    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoRowBounds() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithRowBounds.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    RowBounds bounds1 = new RowBounds(0, 1);
    RowBounds bounds2 = new RowBounds(0, 1);
    AuthorMapperWithRowBounds mapper = sqlSession.getMapper(AuthorMapperWithRowBounds.class);
    mapper.selectAuthor(101, bounds1, bounds2);
  } finally {
    sqlSession.close();
  }
}
项目:MybatisCode    文件:ProviderTest.java   
@Test
public void shouldUseDefaultId() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/MultiDbConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("hsql", c.getDatabaseId());
}
项目:MybatisCode    文件:ProviderTest.java   
@Test
public void shouldUseProvider() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/ProviderConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("translated", c.getDatabaseId());
}
项目:mybatis    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoResultHandlers() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithMultipleHandlers.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    DefaultResultHandler handler1 = new DefaultResultHandler();
    DefaultResultHandler handler2 = new DefaultResultHandler();
    AuthorMapperWithMultipleHandlers mapper = sqlSession.getMapper(AuthorMapperWithMultipleHandlers.class);
    mapper.selectAuthor(101, handler1, handler2);
  } finally {
    sqlSession.close();
  }
}
项目:mybatis    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoRowBounds() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithRowBounds.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    RowBounds bounds1 = new RowBounds(0, 1);
    RowBounds bounds2 = new RowBounds(0, 1);
    AuthorMapperWithRowBounds mapper = sqlSession.getMapper(AuthorMapperWithRowBounds.class);
    mapper.selectAuthor(101, bounds1, bounds2);
  } finally {
    sqlSession.close();
  }
}
项目:mybatis    文件:ProviderTest.java   
@Test
public void shouldUseDefaultId() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/MultiDbConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("hsql", c.getDatabaseId());
}
项目:mybatis    文件:ProviderTest.java   
@Test
public void shouldUseProvider() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/ProviderConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("translated", c.getDatabaseId());
}
项目:mybaties    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoResultHandlers() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithMultipleHandlers.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    DefaultResultHandler handler1 = new DefaultResultHandler();
    DefaultResultHandler handler2 = new DefaultResultHandler();
    AuthorMapperWithMultipleHandlers mapper = sqlSession.getMapper(AuthorMapperWithMultipleHandlers.class);
    mapper.selectAuthor(101, handler1, handler2);
  } finally {
    sqlSession.close();
  }
}
项目:mybaties    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoRowBounds() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithRowBounds.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    RowBounds bounds1 = new RowBounds(0, 1);
    RowBounds bounds2 = new RowBounds(0, 1);
    AuthorMapperWithRowBounds mapper = sqlSession.getMapper(AuthorMapperWithRowBounds.class);
    mapper.selectAuthor(101, bounds1, bounds2);
  } finally {
    sqlSession.close();
  }
}
项目:mybaties    文件:ProviderTest.java   
@Test
public void shouldUseDefaultId() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/MultiDbConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("hsql", c.getDatabaseId());
}
项目:mybaties    文件:ProviderTest.java   
@Test
public void shouldUseProvider() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/ProviderConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("translated", c.getDatabaseId());
}
项目:play    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoResultHandlers() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithMultipleHandlers.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    DefaultResultHandler handler1 = new DefaultResultHandler();
    DefaultResultHandler handler2 = new DefaultResultHandler();
    AuthorMapperWithMultipleHandlers mapper = sqlSession.getMapper(AuthorMapperWithMultipleHandlers.class);
    mapper.selectAuthor(101, handler1, handler2);
  } finally {
    sqlSession.close();
  }
}
项目:play    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoRowBounds() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithRowBounds.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    RowBounds bounds1 = new RowBounds(0, 1);
    RowBounds bounds2 = new RowBounds(0, 1);
    AuthorMapperWithRowBounds mapper = sqlSession.getMapper(AuthorMapperWithRowBounds.class);
    mapper.selectAuthor(101, bounds1, bounds2);
  } finally {
    sqlSession.close();
  }
}
项目:play    文件:ProviderTest.java   
@Test
public void shouldUseDefaultId() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/MultiDbConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("hsql", c.getDatabaseId());
}
项目:play    文件:ProviderTest.java   
@Test
public void shouldUseProvider() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/ProviderConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("translated", c.getDatabaseId());
}
项目:mybatis-3    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoResultHandlers() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithMultipleHandlers.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    DefaultResultHandler handler1 = new DefaultResultHandler();
    DefaultResultHandler handler2 = new DefaultResultHandler();
    AuthorMapperWithMultipleHandlers mapper = sqlSession.getMapper(AuthorMapperWithMultipleHandlers.class);
    mapper.selectAuthor(101, handler1, handler2);
  } finally {
    sqlSession.close();
  }
}
项目:mybatis-3    文件:SqlSessionTest.java   
@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoRowBounds() {
  Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
  configuration.addMapper(AuthorMapperWithRowBounds.class);
  SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
  SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
  try {
    RowBounds bounds1 = new RowBounds(0, 1);
    RowBounds bounds2 = new RowBounds(0, 1);
    AuthorMapperWithRowBounds mapper = sqlSession.getMapper(AuthorMapperWithRowBounds.class);
    mapper.selectAuthor(101, bounds1, bounds2);
  } finally {
    sqlSession.close();
  }
}
项目:mybatis-3    文件:ProviderTest.java   
@Test
public void shouldUseDefaultId() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/MultiDbConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("hsql", c.getDatabaseId());
}
项目:mybatis-3    文件:ProviderTest.java   
@Test
public void shouldUseProvider() throws Exception {
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/ProviderConfig.xml");
  DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
  Configuration c = sqlSessionFactory.getConfiguration();
  assertEquals("translated", c.getDatabaseId());
}
项目:MybatisCode    文件:SqlSessionFactoryBuilder.java   
public SqlSessionFactory build(Configuration config) {
  return new DefaultSqlSessionFactory(config);
}
项目:mybatis    文件:SqlSessionFactoryBuilder.java   
public SqlSessionFactory build(Configuration config) {
  // 源码解析: 创建SqlSession工厂, 传入Configuration对象
  return new DefaultSqlSessionFactory(config);
}
项目:mybaties    文件:SqlSessionFactoryBuilder.java   
public SqlSessionFactory build(Configuration config) {
  return new DefaultSqlSessionFactory(config);
}
项目:sinavi-jfw    文件:JxSqlSessionFactoryTest.java   
@Before
public void instantiate() {
    factory = new JxSqlSessionFactory(new DefaultSqlSessionFactory(null));
}
项目:mybatis-3    文件:SqlSessionFactoryBuilder.java   
public SqlSessionFactory build(Configuration config) {
  return new DefaultSqlSessionFactory(config);
}
项目:ace    文件:TestMybatis.java   
public static void main(String[] args) throws Exception {

        TestH2 h2 = new TestH2();
        // 开始服务
        h2.startServer();
        h2.testH2();

        Class.forName("org.h2.Driver");
        JdbcDataSource JdbcDataSource=new JdbcDataSource();
        JdbcDataSource.setUrl("jdbc:h2:./test");
        JdbcDataSource.setUser("sa");
        JdbcDataSource.setPassword("");


        TransactionFactory transactionFactory = new JdbcTransactionFactory();
        Environment environment = new Environment("Production", transactionFactory, JdbcDataSource);

        Configuration configuration = new Configuration(environment);
        configuration.addMapper(PersonMapper.class);
        SqlSessionFactory sqlSessionFactory = new DefaultSqlSessionFactory(configuration);


        SqlSession sqlSession = sqlSessionFactory.openSession();

        PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);
        Person person=new Person();
        person.setId(1);
        Person person1= personMapper.queryByPrimaryKey(person);
        System.out.println(person1);

        h2.stopServer();


    }
项目:play    文件:SqlSessionFactoryBuilder.java   
/**
 * MyBatis内部通过Configuration对象来创建SqlSessionFactory,
 * 用户也可以自己通过API构造好Configuration对象,调用此方法创建SqlSessionFactory  
 * @param config
 * @return
 */
public SqlSessionFactory build(Configuration config) {
  return new DefaultSqlSessionFactory(config);
}