-
mybatis 一对一关联对象查询
- <select id="getClassInfo" parameterType="int" resultMap="ClassResultMap">
- select * from class c,teacher t where c.teacher_id = t.t_id and c.c_id = #{id}
- </select>
-
- <resultMap type="Classes" id="ClassResultMap">
- <id property="id" column="c_id"/>
- <result property="name" column="c_name"/>
-
- <association property="teacher" column="teacher_id" javaType="Teacher">
- <id property="id" column="t_id"/>
- <result property="name" column="t_name"/>
- </association>
- </resultMap>
- <select id="getClassInfo2" parameterType="int" resultMap="ClassResultMap2" >
- select * from class where c_id = #{id}
- </select>
-
-
- <resultMap type="Classes" id="ClassResultMap2">
- <id property="id" column="c_id"/>
- <result property="name" column="c_name"/>
- <association property="teacher" column="teacher_id"
- javaType="Teacher" select="getTeacher">
- </association>
- </resultMap>
-
- <select id="getTeacher" parameterType="int" resultType="Teacher">
- select t_id id,t_name name from teacher where t_id=#{id}
- </select>
-
-
相关阅读:
VC++数据类型最佳解释
C++类型转换
内核态和用户态
AZMan使用经验点滴
解析#pragma指令(转)
htc使用心得
在VS.net 2008中利用ATL来创建COM关于接口文件的引用变动
移植Reporting Service报表到项目报表
const常量、指向常量的指针和常量指针(转)
extern用法详解(转)
-
原文地址:https://www.cnblogs.com/gtbky/p/8351291.html
Copyright © 2020-2023
润新知