resultMap 的映射

在“查询” 的时候 如果 映射不到 就用resultMap 在映射一遍**
列:在查询可以用 resultType 但是有时候映射不到这里插入图片描述在这里插入图片描述
resultMap 在映射一遍啦

<!-- 映射今日挖矿收益 -->
	<resultMap type="com.maike.miningdevelop.homepage.entity.TotalStoday" id="TotalStoday">
		<result property="currency_img" column="currency_img" />
		<result property="currency_Name" column="currency_Name" />
		<result property="currency_Number" column="currency_Number" />
	</resultMap>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
针对你的问题,我可以回答如下: 使用MyBatis创建resultMap映射的步骤如下: 1. 在MyBatis配置文件中定义resultMap标签。 2. 在resultMap标签中定义id属性、type属性,表示resultMap的唯一标识和映射的类型。 3. 在resultMap标签中使用result标签或者association标签等,定义属性和映射关系。 4. 在SQL语句中使用resultMap标签中定义的id属性,实现查询结果与对象的映射关系。 例如: ``` <resultMap id="userMap" type="com.example.User"> <id property="id" column="id" /> <result property="name" column="name" /> <result property="age" column="age" /> <association property="dept" javaType="com.example.Dept"> <result property="deptName" column="dept_name" /> </association> </resultMap> ``` 上述代码创建了一个resultMap映射,id为userMap,类型为com.example.User,包含id、name、age、dept等属性,dept属性映射为com.example.Dept类型的对象。 使用MyBatis创建动态SQL语句的步骤如下: 1. 在MyBatis配置文件中定义动态SQL语句所在的SQL语句标签,例如select、insert、update、delete等。 2. 在SQL语句标签中使用if标签、choose标签等,根据条件生成动态SQL语句。 3. 在SQL语句标签中使用foreach标签,循环生成动态SQL语句。 4. 在Java代码中调用MyBatis生成的SQL语句进行查询或更新操作。 例如: ``` <select id="getUserList" resultMap="userMap"> SELECT * FROM user <where> <if test="name != null"> AND name = #{name} </if> <if test="age != null"> AND age = #{age} </if> </where> </select> ``` 上述代码创建了一个select标签,id为getUserList,映射结果为userMap。使用where标签实现动态SQL语句,如果name和age都不为null,则生成查询条件name=#{name} and age=#{age}。如果name和age中有一个为null,则不生成相应的查询条件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值