<resultMap id="orderStatusResult" type="Order"> <result property="orderNum" column="order_num" jdbcType="BigInteger"/> <result property="bookId" column="book_id" javaType="Integer"/> </resultMap> <update id="updateOrderStatusThree" parameterMap="orderStatusResult"> update orders o inner join order_detail od on o.order_id = od.order_id set od.status = 3 where o.order_num = #{orderNum} and od.book_id = #{bookId} </update>
时间: 2023-12-05 14:23:57 浏览: 29
这是Mybatis的XML配置文件中的一个update语句,使用了resultMap来映射查询结果到Order对象上,其中orderNum属性映射了数据库表中的order_num列,jdbcType为BigInteger,bookId属性映射了数据库表中的book_id列,javaType为Integer。update语句中使用了内联查询,更新了订单详情表中的status字段为3,条件为订单号和书籍ID。
相关问题
<resultMap type="SysDept" id="SysDeptResult"> <id property="deptId" column="dept_id" /> <result property="parentId" column="parent_id" /> <result property="ancestors" column="ancestors" /> <result property="deptName" column="dept_name" /> <result property="orderNum" column="order_num" /> <result property="leader" column="leader" /> <result property="phone" column="phone" /> <result property="email" column="email" /> <result property="status" column="status" /> <result property="delFlag" column="del_flag" /> <result property="parentName" column="parent_name" /> <result property="createBy" column="create_by" /> <result property="createTime" column="create_time" /> <result property="updateBy" column="update_by" /> <result property="updateTime" column="update_time" /> </resultMap>
这段代码是一个MyBatis的resultMap配置,用于将查询结果映射到SysDept对象上。其中SysDept是一个实体类,包含了与数据库表中字段对应的属性。resultMap中的id标签指定了主键属性,result标签指定了其他属性与数据库列的映射关系。通过这样的配置,查询结果可以自动映射到SysDept对象中的对应属性上。
<resultMap id="eqMapVo" type="EquipmentVo"> <result property="eqId" column="eq_id"/> <result property="companyId" column="company_id"/> <result property="itemName" column="item_name"/> <result property="eqName" column="eq_name"/> <result property="serialNumber" column="serial_number"/> <collection property="maps" javaType="Map"/> </resultMap>中,maps的字段如何指定
在 `<collection>` 标签中,通过 `property` 属性指定集合属性的名称,这里是 `maps`。而 `javaType` 属性指定集合中元素的类型,这里是 `Map`,表示该集合中的元素是 `Map` 类型。如果查询结果中包含了与 `maps` 集合相关的列,可以在 `<collection>` 标签中通过 `<result>` 标签来映射这些列到 `Map` 对象的属性上。例如,如果查询结果中包含了 `key` 和 `value` 两列,可以通过如下方式将它们映射到 `Map` 对象的属性上:
```
<collection property="maps" javaType="Map">
<result column="key" property="key"/>
<result column="value" property="value"/>
</collection>
```
这样,在映射查询结果时,每行记录中的 `key` 和 `value` 列的值都会被封装成一个 `Map` 对象,并添加到 `maps` 集合中。