发布时间:2023-12-11 16:00
public interface UserMapper { List
@Service public class MapTest implements CommandLineRunner { @Autowired private UserMapper mapper; @Override public void run(String... args) throws Exception { List
import org.apache.ibatis.annotations.MapKey; public interface UserMapper { // 指定的key必须是唯一的,否则重复的重复map的key会覆盖,如果查询的字段中没有唯一值,可以通过rowno来指定 @MapKey(\"rowno\") Map> selectTestData2(); }
@Service public class MapTest implements CommandLineRunner { @Autowired private UserMapper mapper; @Override public void run(String... args) throws Exception { Map> mapData1 = mapper.selectTestData2(); System.out.println(mapData1); } }
import org.apache.ibatis.annotations.MapKey; public interface UserMapper { // 指定的key名称必须是User实体类中的属性 @MapKey(\"id\") MapselectTestData3(); }
@Service public class MapTest implements CommandLineRunner { @Autowired private UserMapper mapper; @Override public void run(String... args) throws Exception { MapmapData2 = mapper.selectTestData3(); Set > entries = mapData2.entrySet(); for (Map.Entry entry : entries) { User user = entry.getValue(); System.out.println(user); } } }
以上就是Mybatis返回Map数据方式示例的详细内容,更多关于Mybatis返回Map数据的资料请关注脚本之家其它相关文章!
leetcode 524. Longest Word in Dictionary through Deleting 通过删除字母匹配到字典里最长单词
python学习笔记之读取pdf文件库pdfplumber(一)
Python数据分析--Numpy常用函数介绍(9)--Numpy中几中常见的图形
SphereEx 正式成为 CNCF 会员,持续完善云原生环境下的数据库基础设施
Hadoop(hdfs, yarn, mapreduce)理论详解
c语言中3%3e2%3e1的值,Javascript中的空数组值