当前位置:网站首页>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
边栏推荐
- Using jupyter (I), install jupyter under windows, open the browser, and modify the default opening address
- IOS interview preparation - IOS
- Leetcode (Sword finger offer) - 53 - I. find the number I in the sorted array
- VScode配置makefile编译
- 安装spinning up教程里与mujoco对应的gym,报错mjpro150
- Flink+iceberg environment construction and production problem handling
- GCC Basics
- Classes and objects (I)
- WPS插入超链接无法打开,提示“无法打开指定文件”怎么办!
- Traffic flow prediction pit climbing record (I): traffic flow data set, original data
猜你喜欢

SSM integration, addition, deletion, modification and query

Office提示系统配置无法运行怎么办?

五个关联分析,领略数据分析师一大重要必会处理技能

Classes and objects (I)
![Configure st-gcn environment record [Google lab]](/img/dc/138a40b01ebb4c79b6758d4642d47b.png)
Configure st-gcn environment record [Google lab]

Implementation of img responsive pictures (including the usage of srcset attribute and sizes attribute, and detailed explanation of device pixel ratio)

Flutter 手势监听和画板实现

ssm整合增删改查

电脑无法打开excel表格怎么办?excel打不开的解决方法

A little knowledge about management
随机推荐
Auto.js脚本开发环境搭建
Conv2d of torch
Un7.28: common commands of redis client.
ssm整合增删改查
使用更灵活、更方便的罗氏线圈
Traffic flow prediction pit climbing record (I): traffic flow data set, original data
OpenCV环境搭建
央企建筑企业数字化转型核心特征是什么?
PHP判断用户是否已经登录,如果登录则显示首页,如果未登录则进入登录页面或注册页面
SparkSql批量插入或更新,保存数据到Mysql中
C语言实现三子棋
带你一文理解JS数组
A little knowledge about management
五个关联分析,领略数据分析师一大重要必会处理技能
IOS interview preparation - other articles
How is the entered query SQL statement executed?
Mujoco and mujoco_ Install libxcursor.so 1:NO such dictionary
Conv1d of torch
正确的用户拖拽方式
Leetcode 763. partition labels divide alphabetic intervals (medium)

