摘录自:http://blog.csdn.net/y172158950/article/details/17006127

1. 依据resource获取Reader的sequence图

  1. String resource = "com/test/configuration.xml";//获得xml(Mybatis)数据库连接的连接
  2. Reader reader = Resources.getResourceAsReader(resource);//读取里面的文件

mybatis_helloWorld_sequence图(3)-LMLPHP

2. 依据Reader获取SqlSeesionFactory

  1. SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);//创建session工厂

mybatis_helloWorld_sequence图(3)-LMLPHP

3.  打开SqlSeesion

  1. SqlSession session = sessionFactory.openSession();//打开session

mybatis_helloWorld_sequence图(3)-LMLPHP

4. insert数据的sequence图

  1. flag=session.insert("com.test.Mapper.insertGood",g);

mybatis_helloWorld_sequence图(3)-LMLPHP

好了,整个流程图就画完啦,helloworld就到这

05-11 21:42