Java 不要使用foreach获取mybatis xml中的列表对象值
现在我已经知道如何在MyBatis中的xml foreach循环中获取list参数中的值,但如果在foreach循环中没有,如何获取list元素值?这是我的代码:Java 不要使用foreach获取mybatis xml中的列表对象值,java,Java,现在我已经知道如何在MyBatis中的xml foreach循环中获取list参数中的值,但如果在foreach循环中没有,如何获取list元素值?这是我的代码: <select id="selectMultiRoomSeatForUpdateEnhance" resultMap="roomSeat"> set @update_id := 0; UPDATE r_room_seat s SET
<select id="selectMultiRoomSeatForUpdateEnhance" resultMap="roomSeat">
set @update_id := 0;
UPDATE r_room_seat s
SET s.status = 1,
room_play_id = (SELECT @update_id := max(room_play_id)),
s.user_id = (
case when s.seat_num = 1
then #{queryParam.users[0].id,jdbcType=BIGINT}
when s.seat_num = 2
then #{queryParam.users[1].id,jdbcType=BIGINT}
else 1 end
),
s.robot_flag = (
case when s.seat_num = 1
then #{queryParam.users[0].isRobot,jdbcType=BIGINT}
when s.seat_num = 2
then #{queryParam.users[1].isRobot,jdbcType=BIGINT}
else 0 end
),
WHERE s.status = 0
and s.online = 1
and s.room_play_id in (
select room_play_id
from (
select room_play_id as room_play_id
from r_room_seat
where status = 0
and app_id = 4
group by room_play_id
having count(*) = 2
limit 1
) a
)
and s.room_id = #{queryParam.roomTypeId,jdbcType=BIGINT}
LIMIT 2;
select
<include refid="Base_Column_List"/>
from r_room_seat
where room_play_id = @update_id
limit 1;
</select>
参数如下所示:
/**
* @param queryParam
* @return
*/
RoomSeat selectMultiRoomSeatForUpdateEnhance(@Param("queryParam") Map<String, Object> queryParam);
传递参数:
private RoomSeat getBatchAvailableSeatEnhance(Long roomTypeId, RoomBatchMatchRequest request) {
Map<String, Object> queryParam = new HashMap<>();
queryParam.put("roomTypeId", roomTypeId);
queryParam.put("users", request.getUsers());
RoomSeat roomSeat = roomSeatCustomMapper.selectMultiRoomSeatForUpdateEnhance(queryParam);
return roomSeat;
}
这样指定queryParam.users[1].id是否正确