0
我想從表中獲取所有記錄,同時滿足mybatis select查詢中的特定條件。 作爲一個例子:Mybatis批量選擇查詢 - Java
SELECT * FROM Employee e WHERE e.location = ? AND e.status = ?
組參數經過作爲地圖列表,以產生多個查詢如下。
List = {{location=Colombo, status=available}, {location=Galle, status=onCall}}
SELECT * FROM Employee e WHERE e.location = 'Colombo' AND e.status = 'available'
SELECT * FROM Employee e WHERE e.location = 'Galle' AND e.status = 'onCall'
我想要做的是在批處理模式下運行上述查詢。
在這裏,我試過,但查詢並不像預期的那樣。
<select id="availabeEmployees" parameterType="java.util.List"
resultMap="employeeDtoMap">
SELECT * FROM Employee e
WHERE
<foreach item="item" index="index" collection="list">
e.location = #{item.location}
AND e.status = #{item.status}
</foreach>
</select>