Mybatis的架构包含哪些核心组件和层次,能否详细解释一下?
- 内容介绍
- 文章标签
- 相关推荐
本文共计375个文字,预计阅读时间需要2分钟。
javaMybatis系统中常用的对象包括SqlSessionFactory和SqlSession,创建过程如下:InputStream inputStream=Resources.getResourceAsStream(config/mybatis-config.xml);SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
Mybatis体系常用的对象包括SqlSessionFactory以及SqlSession,创建过程如下:
InputStream inputstream=Resources.getResourceAsStream("config/mybatis-config.xml");
SqlSessionFactory sqlSessionFactoty=new SqlSessionFactoryBuilder().build(inputstream);
SqlSession session=sqlSessionFactoty.openSession();
SqlSessionFactory主要通过注册一个实例来显示,可以通过InputStream来获取mybatis.xml配置文件的地址并以此来建立
。之后SqlSession通过SqlSessionFactory的openSession方法创建。
SqlSession是持久化操作的对象,直接对数据库进行操作。
SqlSession常用方法:
1.int insert(String sql,Object parameter)
其中sql表示的是Mapping映射文件中的方法,即配置文件的id,parameter表示的是要传入的参数
2.int update(String sql,Object parameter)
其中sql表示的是Mapping映射文件中的方法,即配置文件的id,parameter表示的是要传入的参数
3.int delete(String sql,Object parameter)
其中sql表示的是Mapping映射文件中的方法,即配置文件的id,parameter表示的是要传入的参数
4.
本文共计375个文字,预计阅读时间需要2分钟。
javaMybatis系统中常用的对象包括SqlSessionFactory和SqlSession,创建过程如下:InputStream inputStream=Resources.getResourceAsStream(config/mybatis-config.xml);SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
Mybatis体系常用的对象包括SqlSessionFactory以及SqlSession,创建过程如下:
InputStream inputstream=Resources.getResourceAsStream("config/mybatis-config.xml");
SqlSessionFactory sqlSessionFactoty=new SqlSessionFactoryBuilder().build(inputstream);
SqlSession session=sqlSessionFactoty.openSession();
SqlSessionFactory主要通过注册一个实例来显示,可以通过InputStream来获取mybatis.xml配置文件的地址并以此来建立
。之后SqlSession通过SqlSessionFactory的openSession方法创建。
SqlSession是持久化操作的对象,直接对数据库进行操作。
SqlSession常用方法:
1.int insert(String sql,Object parameter)
其中sql表示的是Mapping映射文件中的方法,即配置文件的id,parameter表示的是要传入的参数
2.int update(String sql,Object parameter)
其中sql表示的是Mapping映射文件中的方法,即配置文件的id,parameter表示的是要传入的参数
3.int delete(String sql,Object parameter)
其中sql表示的是Mapping映射文件中的方法,即配置文件的id,parameter表示的是要传入的参数
4.

