Mybatis相应API

Mybatis相应API

1、SqlSession工厂构造器SqlSessionFactoryBuilder
Mybatis相应API

2、SqlSession工厂对象sqlSessionFactoryMybatis相应API
3、SqlSession会话对象
Mybatis相应API

<!--查询一个数据-->
    <select id="findBy" resultType="user" parameterType="int">
        select  * from user where id=#{id}
    </select>
 @Test
    public void test05() throws IOException {
        //获得核心配置文件
        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
        //获得session工厂对象
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        //获得session回话对象
        SqlSession sqlSession = sqlSessionFactory.openSession();
        //执行操作 参数:namespace+id
        User user = sqlSession.selectOne("userMapper.findBy", 1);
        //打印数据
        System.out.println(user);
        //释放资源
        sqlSession.close();
    }
上一篇:什么?你还在用EventBus吗?快来试试用Flow api搞一个


下一篇:VTK获取单个单元的体积