Mybatis的架构体系是怎样的?
- 内容介绍
- 文章标签
- 相关推荐
本文共计391个文字,预计阅读时间需要2分钟。
plaintextMybatis系统中常用的对象包括SqlSessionFactory和SqlSession,它们是构建数据库交互的关键组件。创建过程如下:InputStream inputStream=Resources.getResourceAsStream(config/mybatis-config.xml);SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
x.textMybatis体系常用的对象包括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.
本文共计391个文字,预计阅读时间需要2分钟。
plaintextMybatis系统中常用的对象包括SqlSessionFactory和SqlSession,它们是构建数据库交互的关键组件。创建过程如下:InputStream inputStream=Resources.getResourceAsStream(config/mybatis-config.xml);SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
x.textMybatis体系常用的对象包括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.

