myBatis学习笔记(1)
myBatis一般执行过程:
(1)String resource = "myBatis-config.xml";
(2)Reader reader = Resources.getResourceAsReader(resource);
(3)sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
(4)SqlSession session = sqlSessionFactory.openSession();
(5)Ticket ticket= (Ticket)sqlSession.selectOne("org.mybatis.example.BlogMapper.yy", id);
(6)sqlSession.close();
如使用用连接池:
将步骤(3)的SqlSessionFactoryBuilder类对象用SqlSessionFactoryBean对象代替,并为其配置配置文件及
连接池对象的属性变量,则其产生的SqlSession对象即具有连接池特性。
逆天改命!我命由我不由天!