- 浏览: 732631 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (663)
- Eclipse&MyEclipse (40)
- PHP (3)
- Java (72)
- CSS (3)
- MySQL (35)
- Oracle (68)
- Red Hat Linux (23)
- Tomcat (26)
- Oracle10gAS (1)
- Spring (28)
- MyBatis&iBatis (13)
- JS (47)
- JQuery (23)
- Editplus (2)
- 其他 (4)
- Html (15)
- SQL (5)
- Ant (2)
- Hadoop (2)
- Servlet (9)
- Windows (11)
- Flex (1)
- CentOS Linux (7)
- Microsoft SQL Server (2)
- DB2 (3)
- Mysql char 与 varchar 区别 (0)
- excel (5)
- jsp (8)
- FreeMarker (1)
- EasyUI (5)
- WebShpere MQ (1)
- Maven2 (6)
- 浏览器缓存 (2)
- visio (1)
- XML (2)
- 物联网 (1)
- Maven (3)
- JSTL (2)
- HTTP (1)
- Fourinone (1)
- IP知识 (1)
- MyBatis (1)
- 项目管理 (2)
- office2003+2007 (1)
- DOS (1)
- JProfiler (1)
- Thinpad T440p (1)
- ActiveMQ (10)
- MongoDB (5)
- Vert.x3 (1)
- Ngnix (3)
- Spark (2)
- BigData (1)
- 性能概念公式 (1)
- RocketMQ (3)
- IT名词术语 (1)
- Java编程工具 (1)
- RabbitMQ (2)
- MetaMQ (1)
- 架构 (6)
- KafkaMQ (7)
- Redis (4)
- OAuth (1)
- Gradle (1)
- CentOS (5)
- Microsoft_Toolkit (1)
- git (5)
- IntelliJ Idea (4)
- Nginx (3)
- docker (12)
- VMware (2)
- 算法 (1)
- JDBCPool (1)
- spring-cloud (7)
- netbean (1)
- 微信小程序 (2)
- CURL (2)
- Java生成二维码 (1)
- 区块链 (2)
- 机器学习 (1)
- SpringBoot (3)
- Android (9)
- 微服务架构 (1)
- Kubernetes (2)
- OpenProject (0)
- 测试 (1)
- https (1)
- 开源许可证 (1)
- ServiceMesh (2)
- NET (0)
- .NET (1)
- TEST (1)
- iOS (2)
- thymeleaf (4)
- lombok (1)
- 浏览器设置 (1)
- 富文本编辑器 (1)
- 搜索引擎 (1)
- IT常识 (1)
- UML (0)
- Axure (1)
- appstore无法联网 (0)
- apk无法安装 (1)
- SQLServer (2)
- 卸载弹窗软件 (1)
- jenkins (1)
- TortoiseGit (1)
- eureka (1)
- ajax (1)
- spyder (0)
最新评论
mybatis 一对一 一对多
一对一的XML配置文件
<mapper namespace="dao.mapper.ClassMapper">
<resultMap id="classResultMap" type="Classes">
<id property="classid" column="classid1" />
<result property="classname" column="classname" />
<result property="teacherid" column="teacherid2" />
<association property="teacher" column="teacherid" javaType="Teacher" select="getTeacher" />
<!-- <association property="teacher" column="teacherid" javaType="Teacher" select="dao.mapper.TeacherMapper.getTeacher" /> 两个XML文件之间调用 -->
</resultMap>
<select id="selectAllByClassId" parameterType="int" resultMap="classResultMap">
select * from class c where c.classid = #{classid};
</select>
<select id="getTeacher" parameterType="int" resultType="teacher">
select * from teacher tt where tt.teacherid = #{teacherid2}
</select>
</mapper>
一对多 两个配置文件之间调用
一对多中的"一"
<mapper namespace="dao.mapper.ClassMapper">
<resultMap id="classResultMap" type="Classes">
<id property="classid" column="classid1" />
<result property="classname" column="classname" />
<result property="teacherid" column="teacherid2" />
<collection property="studentList" column="classid" javaType="ArrayList" ofType="Student" select="StudentDao.getStudentByClassID" />
</resultMap>
<select id="selectAllByClassId" parameterType="int" resultMap="classResultMap">
select * from class c where c.classid = #{classid};
</select>
</mapper>
一对多中的"多"
<mapper namespace="StudentDao">
<resultMap type="Student" id="studentResultMap">
<id property="studentid" column="studentid" />
<result property="studentname" column="studentname" />
</resultMap>
<!-- 查询学生list,根据班级id -->
<select id="getStudentByClassID" parameterType="String" resultMap="studentResultMap">
select *from student st WHERE st.classid = #{classid1}
</select>
</mapper>
一对一的XML配置文件
<mapper namespace="dao.mapper.ClassMapper">
<resultMap id="classResultMap" type="Classes">
<id property="classid" column="classid1" />
<result property="classname" column="classname" />
<result property="teacherid" column="teacherid2" />
<association property="teacher" column="teacherid" javaType="Teacher" select="getTeacher" />
<!-- <association property="teacher" column="teacherid" javaType="Teacher" select="dao.mapper.TeacherMapper.getTeacher" /> 两个XML文件之间调用 -->
</resultMap>
<select id="selectAllByClassId" parameterType="int" resultMap="classResultMap">
select * from class c where c.classid = #{classid};
</select>
<select id="getTeacher" parameterType="int" resultType="teacher">
select * from teacher tt where tt.teacherid = #{teacherid2}
</select>
</mapper>
一对多 两个配置文件之间调用
一对多中的"一"
<mapper namespace="dao.mapper.ClassMapper">
<resultMap id="classResultMap" type="Classes">
<id property="classid" column="classid1" />
<result property="classname" column="classname" />
<result property="teacherid" column="teacherid2" />
<collection property="studentList" column="classid" javaType="ArrayList" ofType="Student" select="StudentDao.getStudentByClassID" />
</resultMap>
<select id="selectAllByClassId" parameterType="int" resultMap="classResultMap">
select * from class c where c.classid = #{classid};
</select>
</mapper>
一对多中的"多"
<mapper namespace="StudentDao">
<resultMap type="Student" id="studentResultMap">
<id property="studentid" column="studentid" />
<result property="studentname" column="studentname" />
</resultMap>
<!-- 查询学生list,根据班级id -->
<select id="getStudentByClassID" parameterType="String" resultMap="studentResultMap">
select *from student st WHERE st.classid = #{classid1}
</select>
</mapper>
发表评论
-
mybatis嵌套循环map(高级用法)(转)
2019-10-04 15:23 363版权声明:本文为博主原创文章,遵循 CC 4.0 ... -
mybatis批量更新的两种实现方式(转)
2018-05-13 19:05 536一:当要更新的内容是不样的 mapper.xml文件,后台 ... -
Mybatis的Mapper的多参数使用,list (转)
2015-07-02 18:04 2020Mapper中多参数查询, 批量更新 参数包括Str ... -
mybatis执行批量更新batch update 的方法(oracle,mysql)
2014-12-12 19:23 0oracle和mysql数据库的批量update在mybat ... -
源码解读Mybatis List列表In查询实现的注意事项 (转)
2014-06-01 13:07 807原作者:http://www.blogjava.net/xm ... -
mybatis foreach *用法*(转)
2013-06-29 11:19 1137在SQL开发过程中,动态构建In集合条件查询是比较常见的 ... -
MyBatis中出现Mapped Statements collection does not contain value(转)
2012-12-12 10:00 1356java.lang.IllegalArgumentExcept ... -
MyBatis 学习 (转)
2012-11-08 23:16 845“肖凡的专栏” 博客,请务必保留此出处http://legen ... -
元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,di
2012-11-05 10:29 2182Caused by: org.xml.sax.SAXParse ... -
sql中查询类型为int的字段,返回null的异常
2012-10-02 21:00 0项目中用mybatis3.x,用sql查询某个表类型为int的 ... -
myBatis 防止批量update delete select(转)原作者 程明东
2012-09-21 15:51 2148原作者 程明东 http://my.oschina.net ... -
MyBatis association 正确使用
2012-09-10 01:33 1580<resultMap id="sysPerm ... -
java.lang.IllegalArgumentException: Mapped Statements collection does not contai
2012-08-09 13:43 1577java.lang.IllegalArgumentExcept ... -
iBatis sql map文件中的”不等号“用法
2012-03-07 10:14 22601. <isNotEmpty property=&q ...
相关推荐
mybatis一对多的查询方法详解! mybatis一对多的查询方法详解! mybatis一对多的查询方法详解! mybatis一对多的查询方法详解!
MyBatis简单的一对一和一对多测试,表根据JavaBean自己创建,测试已通过
自己根据mybatis文档测试其中的一对一,一对多,association,collection的使用,更有利于理解。
mybatis 一对多性能优化 demo mybatis 一对多性能优化 demo
MyBatis一对多映射实例,代码完整,可运行
【MyBatis学习笔记六】——MyBatis一对一,一对多,多对一,多对多.zip博客地址:https://blog.csdn.net/weixin_43817709/article/details/117537580
就是代码而已《哈哈哈》
mybatis 一对多 多对一
一对多的选择和插入,数据比较简单,自己建立一下表
Mybatis的一对一,一对多
mybatis 一对一 一对多例子 oracle 数据库 ,xml配置,方法
Mybatis实现一对一、一对多关联查询,关联查询:多个表联合查询,只查询一次,通过resultMap里面的、标签配置一对一、一对多;涉及到的一对一、一对多关系: - 班级classes、班主任teacher是一对一的关系 - 班级...
MyBatis高级映射(一对多查询)
Mybatis实现关联查询一对一和一对多实现,具体效果看博文 http://blog.csdn.net/evankaka/article/details/45674101
一对多,从多得一方取出一的一方.只是一个小例子,表结构能才出来的
Mybatis实现一对一,一对多数据插入数据实验报告
mybatis(一对多xml)
举个例子:每个人可以拥有多个银行卡(一对多)、每张银行卡只会对应一个用户(一对一)、每个人可能拥有多个不同的社会角色,每一个不同的社会角色也会对应不同的人(多对多),Mybatis作为大名鼎鼎的SSM的组成部分...
实现Mybatis框架中一对多关联映射的查询操作。 User用户表 - Order_form订单表属于 1-N 的关系。 一个用户对象包含一批订单信息