当前位置:网站首页>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>
边栏推荐
- LeetCode:236. The nearest common ancestor of binary tree
- What is an R-value reference and what is the difference between it and an l-value?
- CSP salary calculation
- 五层网络体系结构
- Multivariate cluster analysis
- Leetcode刷题题解2.1.1
- Mongodb installation and basic operation
- Advanced Computer Network Review(5)——COPE
- 数学建模2004B题(输电问题)
- I-BERT
猜你喜欢

KDD 2022论文合集(持续更新中)

Intel distiller Toolkit - Quantitative implementation 3

I-BERT

Redis之发布订阅

A convolution substitution of attention mechanism

Selenium+pytest automated test framework practice

Mise en œuvre de la quantification post - formation du bminf

Redis之主从复制

IDS cache preheating, avalanche, penetration

Blue Bridge Cup_ Single chip microcomputer_ PWM output
随机推荐
Intel Distiller工具包-量化实现3
Redis geospatial
Pytorch view tensor memory size
Go redis initialization connection
Selenium+Pytest自动化测试框架实战
Leetcode: Jianzhi offer 03 Duplicate numbers in array
甘肃旅游产品预订增四倍:“绿马”走红,甘肃博物馆周边民宿一房难求
Kratos ares microservice framework (II)
Parameterization of postman
Different data-driven code executes the same test scenario
[oc]- < getting started with UI> -- learning common controls
Post training quantification of bminf
Intel distiller Toolkit - Quantitative implementation 3
Mathematical modeling 2004b question (transmission problem)
[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
How to intercept the string correctly (for example, intercepting the stock in operation by applying the error information)
An article takes you to understand the working principle of selenium in detail
Connexion d'initialisation pour go redis
[three storage methods of graph] just use adjacency matrix to go out
Redis之发布订阅