随笔分类 -  MyBatis

MyBatis查询:一对多映射关系
摘要:@Mapper public interface ParameterMapper { Dept GetDeptAndEmp(@Param("id") Integer did); } <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PU 阅读全文
posted @ 2022-06-10 23:10 西凉# 阅读(43) 评论(0) 推荐(0)
MyBatis查询:多对一映射关系
摘要:通过级联属性复制解决多对一的映射关系 通过association解决多对一的映射关系 通过级联属性复制解决多对一的映射关系 Mapper层 @Mapper public interface ParameterMapper { Emp GetEmpAndDept(@Param("id") Intege 阅读全文
posted @ 2022-06-10 22:21 西凉# 阅读(37) 评论(0) 推荐(0)
回顾jdbc
摘要:@Autowired private ParameterMapper parameterMapper; //回顾jdbc占位符拼接 @Test public void fun1() throws Exception { String username="张三"; Class.forName("com 阅读全文
posted @ 2022-06-10 22:02 西凉# 阅读(22) 评论(0) 推荐(0)
resultMap解决字段名和属性名不一致
摘要:id设置主键的映射关系 result设置普通字段的映射关系 就算属性名和字段名一样也要设置映射关系,不能省略! type是实体类 property:设置映射关系中的属性名,必须是type属性所设置的实体类类型中的属性名 column:设置映射关系中的字段名,必须是sql语句查询出的字段名 resul 阅读全文
posted @ 2022-06-10 19:35 西凉# 阅读(47) 评论(0) 推荐(0)