3-29博客

来源:互联网 发布:mac照片占用空间 编辑:程序博客网 时间:2024/05/18 00:35

今天主要学习了对象与对象的关系

分为:一对一,一对多,多对多

以及sql的批量联合添加和多对多的链表查询


批量联合中间表添加数据sql:

<insert id="addStuAndCourse">
insert into t_studentCourse(fk_studentId,fk_courseId) values
<foreach collection="list" item="sc" separator=",">
(#{sc.student.id},#{sc.course.id})
</foreach>
</insert>


多对多时子查询:

select id as id,courseName as courseName from t_course where id in (select fk_courseId from t_studentCourse where fk_studentId = #{id})


缓存技术:

1、缓存中可以放(小数据,低并发,不经常修改)

2、缓存分为一级缓存和二级缓存

3、一级缓存失效后二级缓存就会自动开启


遇到的问题:

1、<resultMap> 的id写错

2、批量联合中间表添加时封装数据

3、最开始一对多和多对多的了解不是很详细,做作业时搞混

4、中间表sql对应id实体对应的对象集合

0 0
原创粉丝点击