当前位置:网站首页>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
边栏推荐
- Flink+Iceberg环境搭建及生产问题处理
- Go面向并发的内存模型
- IOS interview preparation - Objective-C
- Mujoco and mujoco_ Install libxcursor.so 1:NO such dictionary
- SSM integration, addition, deletion, modification and query
- UE plays video in scene or UMG
- 荣耀2023内推,内推码ambubk
- leetcode 763. Partition Labels 划分字母区间(中等)
- How to debug UDP port
- Implementation of img responsive pictures (including the usage of srcset attribute and sizes attribute, and detailed explanation of device pixel ratio)
猜你喜欢

Corresponding order of 18 and 25coco data of openpose and joint points

怎样监测微型的网站服务

The most comprehensive promotion plan for the launch of new products

Traffic flow prediction pit climbing record (I): traffic flow data set, original data

Install the gym corresponding to mujoco in the spinning up tutorial, and the error mjpro150 is reported

安装spinning up教程里与mujoco对应的gym,报错mjpro150

如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然

Excel怎么筛选出自己想要的内容?excel表格筛选内容教程

EMI interference troubleshooting with near-field probe and current probe

On prepayment of house purchase
随机推荐
网络之以太网
Detailed comparison of break and continue functions
[untitled]
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
How to debug UDP port
Flutter 手势监听和画板实现
Wps如何使用智能填充快速填充数据?Wps快速填充数据的方法
On prepayment of house purchase
UE 在场景或UMG中播放视频
Leetcode 763. partition labels divide alphabetic intervals (medium)
GCC基础知识
Using jupyter (I), install jupyter under windows, open the browser, and modify the default opening address
How to set row height and column width in excel? The method of setting row height and column width in Excel
Software test interview questions (4)
Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案
1 句代码,搞定 ASP.NET Core 绑定多个源到同一个类
Nail dialog text converted to pictures cannot be copied and pasted on the document
SSM integration, addition, deletion, modification and query
Classes and objects (II)

