上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 40 下一页
摘要: 多参数查询,使用parameterType。实例: 用户User[id, name, age] 1.mysql建表并插入数据 2.Java实体类 public class User { public User() { } public User(int id, String name, int ag 阅读全文
posted @ 2016-02-24 22:14 艺言弈行 阅读(4544) 评论(0) 推荐(0) 编辑
摘要: 和第5节一对一查询类似,但是不同的是,一对一使用的是association,而一对多使用collection。 实例: 1个班级Class,对应1个老师Teacher,对应多个学生Student 1.建表如下: class[cid, cname, tid] teacher[tid, tname] s 阅读全文
posted @ 2016-02-23 22:38 艺言弈行 阅读(712) 评论(0) 推荐(0) 编辑
摘要: 在xxxMapper中 <select id="getClazz" parameterType="int" resultType="getClazzMap"> SELECT * FROM class c,teacher t WHERE c.tid = t.tid AND c.cid=#{id} </ 阅读全文
posted @ 2016-02-23 00:11 艺言弈行 阅读(35231) 评论(3) 推荐(2) 编辑
摘要: 方式一:嵌套结果:使用嵌套结果映射来处理重复的联合结果的子集,封装联表查询的数据(去除重复的数据) SELECT * FROM class c,teacher t WHERE c.tid = t.tid AND c.cid=#{id} 方式二:嵌套查询,通过执行另外一个SQL 映射语句来返回预期的复 阅读全文
posted @ 2016-02-22 23:37 艺言弈行 阅读(521) 评论(0) 推荐(0) 编辑
摘要: /** * 属性和表的列名不相同时的处理方法 * 1.sql中给列重新命名: * select tid id, tname name from teacher t where tid=#{id} * 2.在teacherMapper.xml中使用resultMap标签 * <select id="g 阅读全文
posted @ 2016-02-22 23:28 艺言弈行 阅读(1206) 评论(0) 推荐(0) 编辑
上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 40 下一页