当前位置:网站首页>Mapper agent development
Mapper agent development
2022-07-29 04:54:00 【Chen Yuchen】
Mapper Agent development
Mapper Concept of agent development
We used to write code in a basic way , It also has the problem of hard coding ( Too high coupling ): as follows
// perform sql list<User>users = sqlSession.selectList("test.selectAll"); System.out.println(users);
This call selectList() Method pass parameters are in the mapping configuration file namespace.id value . This is not convenient for later maintenance . If you use Mapper The way of agency is as follows , Then the coupling degree can be reduced//3. Get proxy object UserMapper userMapper = SqlSession.getMapper(UserMapper.class); //4. Execution method , It's actually execution sql sentence List<User>users=userMapper.selectAll();
As can be seen from the above description Mapper The purpose of agency :
Reduced coupling
Simplify late execution SQL
stay MyBatis The official website is also recommended Mapper Agency mode .
Use Mapper Agency request
Use Mapper Agency mode , The following requirements must be met :
Definition and SQL Mapping files with the same name Mapper Interface , And will Mapper Interface and SQL The mapping files are placed in the same directory . Here's the picture
Set up SQL Mapping files namespace The attribute is Mapper The interface is fully qualified
<!--
namespace: The name space , Must be the fully qualified name of the corresponding interface
-->
<mapper namespace="com.itheima.mapper.UserMapper">
stay Mapper Define methods in interfaces , The method name is SQL In the mapping file sql Of the statement id, And keep the parameter type consistent with the return value type
边栏推荐
- < El table column> place multiple pictures
- [untitled]
- 删除word文档中的空白页
- Glory 2023 push, push code ambubk
- Torch.nn.crossentropyloss() details
- Command line interactive tools (latest version) inquirer practical tutorial
- Opencv learning 1 (environment configuration)
- Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
- 如何避免示波器电流探头损坏
- After the spinning up installation is completed, use the tutorial to test whether it is successful. There are library "Glu" not found and 'from pyglet.gl import * error solutions
猜你喜欢

WPS插入超链接无法打开,提示“无法打开指定文件”怎么办!

Improve the readability of your regular expressions a hundred times

Glory 2023 push, push code ambubk

Reveal安装配置调试

Mujoco and mujoco_ Install libxcursor.so 1:NO such dictionary

如何避免示波器电流探头损坏

Delete blank pages in word documents

< El table column> place multiple pictures

命令行交互工具(最新版) inquirer 实用教程

使用近场探头和电流探头进行EMI干扰排查
随机推荐
Go面向并发的内存模型
def fasterrcnn_ resnet50_ FPN () instance test
DataSourceClosedException: dataSource already closed at Mon Oct 25 16:55:48 CST 2021
Basic grammar of C language
stack和queue和优先级队列(大堆和小堆)模拟实现和仿函数讲解
Makefile+make Basics
How to build a mobile studio network?
How to avoid damage of oscilloscope current probe
< El table column> place multiple pictures
Conv1d of torch
Mujoco and mujoco_ Install libxcursor.so 1:NO such dictionary
1 sentence of code, get asp Net core binds multiple sources to the same class
Google browser opens the web page and out of memory appears
使用更灵活、更方便的罗氏线圈
Learn matlab to draw geographical map, line scatter bubble density map
MySQL time calculation function
On prepayment of house purchase
EF Core: 一对一,多对多的配置
Vscode configuration makefile compilation
Go memory model for concurrency

