Java学习 --- mybatisPlus实现自定义方法
一、mybatisPlus实现自定义方法1、创建映射文件2、自定义方法/*** 根据map集合id查询用户* @param id* @return*/Map<String ,Object> selectMapId(Long id);3、UserMapper.xml<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapp
·
一、mybatisPlus实现自定义方法
1、创建映射文件
2、自定义方法
/**
* 根据map集合id查询用户
* @param id
* @return
*/
Map<String ,Object> selectMapId(Long id);
3、UserMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cjc.mybatisplus.mapper.UserMapper">
<!--selectMapId-->
<select id="selectMapId" resultType="map">
select id,name,age,email from user where id = #{id}
</select>
</mapper>
4、测试方法
/**
* 测试自定义接口
*/
@Test
public void selectUserMapId(){
Map<String, Object> userMap = userMapper.selectMapId(3L);
System.out.println("userMap=" + userMap);
}

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)