mybatis返回map<list>
时间: 2023-10-25 13:32:12 浏览: 127
MyBatis can return a Map<List>
by configuring the result map appropriately. Here are the steps to achieve this:
- Define a ResultMap in your MyBatis configuration XML file:
```xml
Use the defined ResultMap in your SQL query:
<select id="yourQuery" resultMap="myResultMap"> <!-- your SQL query --> </select>
In your Java code, retrieve the result as a
Map<List>
:Map<String, List<YourClass>> resultMap = sqlSession.selectOne("yourQuery"); List<YourClass> myList = resultMap.get("myList");
Make sure to replace your.package.YourClass
with the appropriate class that represents the elements of the list you want to retrieve.
阅读全文
相关推荐


















