当前位置:网站首页>Solve the problem of inconsistency between database field name and entity class attribute name (resultmap result set mapping)
Solve the problem of inconsistency between database field name and entity class attribute name (resultmap result set mapping)
2022-07-06 09:17:00 【c-vking】
problem
Database fields :id name pwd
Entity class properties :id name password
Query results :password Query as null
reason :
sql sentence :select * from mybatis.user where id = #{id}
It's actually :select id,name,pwd from mybatis.user where id = #{id}
And the output user Of password Property has no assignment , So for null
resolvent :
1. names ( understand )
select id,name,pwd as password from mybatis.user where id = #{id}
2. Use resultMap Result set mapping
<resultMap id="userMap" type="user">
<!--property Properties in entity classes ,column Fields in the database -->
<result property="password" column="pwd"/>
</resultMap>
<select id="getUserById" resultMap="userMap" parameterType="int">
select * from mybatis.user where id = #{id}
</select>
边栏推荐
- Mysql database recovery (using mysqlbinlog command)
- Selenium+Pytest自动化测试框架实战(下)
- MySQL uninstallation and installation methods
- Export IEEE document format using latex
- 七层网络体系结构
- 一篇文章带你了解-selenium工作原理详解
- Kratos ares microservice framework (I)
- [shell script] use menu commands to build scripts for creating folders in the cluster
- QML type: locale, date
- A convolution substitution of attention mechanism
猜你喜欢

Advanced Computer Network Review(3)——BBR
![[three storage methods of graph] just use adjacency matrix to go out](/img/79/337ee452d12ad477e6b7cb6b359027.png)
[three storage methods of graph] just use adjacency matrix to go out

Redis之哨兵模式

Redis cluster

Blue Bridge Cup_ Single chip microcomputer_ PWM output

Intel distiller Toolkit - Quantitative implementation 3

CUDA realizes focal_ loss

Redis之cluster集群

一改测试步骤代码就全写 为什么不试试用 Yaml实现数据驱动?

Redis' bitmap
随机推荐
Leetcode: Jianzhi offer 03 Duplicate numbers in array
A convolution substitution of attention mechanism
注意力机制的一种卷积替代方式
[sword finger offer] serialized binary tree
Selenium+Pytest自动化测试框架实战
IDS' deletion policy
AcWing 2456. Notepad
Kratos ares microservice framework (I)
【shell脚本】——归档文件脚本
Pytest参数化你不知道的一些使用技巧 /你不知道的pytest
requests的深入刨析及封装调用
[oc]- < getting started with UI> -- common controls - prompt dialog box and wait for the prompt (circle)
Redis之持久化实操(Linux版)
Le modèle sentinelle de redis
QML type: locale, date
Advanced Computer Network Review(3)——BBR
LeetCode:34. Find the first and last positions of elements in a sorted array
Intel Distiller工具包-量化实现2
什么是MySQL?MySql的学习之路是怎样的
Leetcode problem solving 2.1.1