mybatis 中collection 的用法
来源:互联网 发布:淘宝用邮箱怎么注册 编辑:程序博客网 时间:2024/06/06 12:29
一、数据模型
2、Entity
Doctor
public class Doctor extends DataEntity<Doctor>{private static final long serialVersionUID = 1L;private String doctorName ; //医生姓名private String title ; //医生的职称(中文)private String hisCode; //医生的his编码private String pym ; //医生姓名对应的拼音(由系统跟据用户注册时,自动生成)private String depId ; <span style="white-space:pre"></span> //医生所属科室 (t_department.id)private String note ; //医生的简历private String photo; //医生的照片private String status ; //医生的状态(1有效,2无效)private String hospitalId; <span style="white-space:pre"></span> //医生所属医院的ID (t_hospital.id)private String isedit ; //是否编辑private Department department; <span style="white-space:pre"></span> //科室管理private boolean isSelf ; //是否对自己操作 (默认对自己操作)private List<Schedule> scheduleList;
Schedule
public class Schedule extends DataEntity<Schedule> {private static final long serialVersionUID = 1L;private String hbName; <span style="white-space:pre"></span>//号别名称private String pbHisCode;//排班his编号private String deptHisCode; <span style="white-space:pre"></span>//科室his编号private String doctorHisCode; <span style="white-space:pre"></span>//医生his编号private java.sql.Timestamp pbDate; //排班日期(2016-01-01)private String pbTime; <span style="white-space:pre"></span>//排班时段(1为上午,2为下午,3为白天,4为晚上)private String fenshiFlag; <span style="white-space:pre"></span>//分时类型(1分时间点,2分时间段,3不分时)private Integer totalCount;// 总挂号数private Integer count; //已挂号数private Integer price;//价格private String status; //状态(1为正常/2为停诊)private Hospital hospital;//所属医院private Doctor doctor; <span style="white-space:pre"></span>//医生信息 gettering and settering
3、 xml mapping
最终数据返回List<Doctor> , column:对应数据库中的列名/别名 ,property:对应Entity中属性名
<resultMap id="scheduleInfoColumns" type="com.thinkgem.jeesite.modules.guahao.yygh.entity.Doctor"><id column="id" property="id"/><result column="doctor_name" <span style="white-space:pre"></span>property="doctorName"/><result column="title" property="title"/><collection property="scheduleList" ofType="com.thinkgem.jeesite.modules.guahao.yygh.entity.Schedule"><id property="id" olumn="scheduleList.id"/><result property="hbName" column="scheduleList.hbName"/><result property="pbHisCode" column="scheduleList.pbHisCode"/><result property="deptHisCode" column="scheduleList.deptHisCode"/><result property="doctorHisCode" column="scheduleList.doctorHisCode"/><result property="pbDate" column="scheduleList.pbDate"/><result property="pbTime" column="scheduleList.pbTime"/><result property="fenshiFlag"column="scheduleList.fenshiFlag"/><result property="totalCount" column="scheduleList.totalCount"/><result property="count" column="scheduleList.count"/><result property="price" column="scheduleList.price"/></collection></resultMap>
SQL
<select id="findScheduleInfo" resultMap="scheduleInfoColumns"> SELECT doc.id as id , doc.doctor_name as doctor_name, doc.title as title , doc.his_code as his_code , s.id as "scheduleList.id" , s.hb_name as "scheduleList.hbName", s.pb_his_code as "scheduleList.pbHisCode", s.dept_his_code as "scheduleList.deptHisCode" , s.pb_date as "scheduleList.pbDate", s.pb_time as "scheduleList.pbTime", s.fenshi_flag as "scheduleList.fenshiFlag", s.totalcount as "scheduleList.totalCount", s.count as "scheduleList.count", s.price as "scheduleList.price" FROM T_DOCTOR doc left join T_DEPARTMENT dep on dep.id = doc.depid inner join T_SCHEDULE s on s.dept_his_code = dep.his_code WHERE s.status = '1' AND dep.status = '1' AND doc.status = '1' AND doc.depid = #{id} AND s.dept_his_code = #{hisCode} AND s.hospital_id = #{hospitalId} AND s.dept_his_code = dep.his_code AND s.doctor_his_code = doc.his_code AND s.pb_date between to_date(sysdate) AND to_date(sysdate+27) and rownum <29; </select>
SQL 查询
2、Entity
Doctor
0 0
- mybatis 中collection 的用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法之Array
- mybatis中foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis 中 foreach collection的三种用法
- mybatis foreach collection 用法
- SPA:React + React-router 入门demo
- 笔记2 编码,格式化
- HTTP 协议
- 属性动画和Activity、Fragment过渡动画等
- Spring MVC框架
- mybatis 中collection 的用法
- AM1705定时器寄存器读取
- Dubbo 开发者指南
- 跳 [Codevs 1515]
- Java方法参数的传递机制,值传递?引用传递?
- 排行榜妙用——CSS计数器
- android环境下两种md5加密方式
- 高德地理编码和逆地理编码区别
- 指定图表的列表页