Mybatis两表联查,不需要配置xml!
来源:互联网 发布:22lr子弹数据 编辑:程序博客网 时间:2024/04/28 18:17
Mybatis大家一定用的很多 , 我不多啰嗦了;
用mybatis做两表联查怎么办呢?
假如有A,B两张表 , 一般是在A的pojo中添加B的主键(如果需要也可以添加其他属性) , 然后在映射的xml中配置
这种方法是不是很low呢?假如我两张表的属性都很多呢???
我要介绍的就是不需要配置xml,就能查询出联表的数据,
很简单 , 只需要在A表里配B表的主键,然后再映射里写sql
eg:
<select id="selectAll" resultType=""hashMap"">
select * from t_A a left join T_B b on a.bid = b.bid
</select>
(注意标红的部分!)
在Service层处理的时候要用List接收;
不多说了,
这是我的代码地址:https://github.com/wangdehua/ssm-maven/commit/820d53f144bcb567c61c647f3eecab8031380ed1
0 0
- Mybatis两表联查,不需要配置xml!
- spring+mybatis整合,不需要配置映射文件,多路径配置
- mybatis generator.xml 配置
- MyBatis基于XML配置
- mybatis的xml配置
- [mybatis]基本XML配置
- 配置mybatis Catalog xml
- mybatis 配置sqlMapConfig.xml
- Mybatis.xml配置
- 使用xml配置Mybatis
- Mybatis-SqlMapConfig.xml配置
- mybatis SqlMap.xml配置
- mybatis配置XML文件
- mybatis-config.xml配置
- spring-MyBatis.xml配置
- Mybatis xml配置
- Mybatis--XML配置
- mybatis-xml配置
- order by 降序desc,升序asc,排名函数 rank()over()
- bzoj 1925 DP+滚动数组
- VB DoEvents 的使用
- Spring 配置异常解决办法之Referenced file contains errors
- H5页面跳转与传值
- Mybatis两表联查,不需要配置xml!
- 用checkinstall制作deb/rpm/Slackware安装包
- Android Studio的搭建
- or和and的使用
- php 笔试题(一)
- 数组左移p位(2种方法)
- 多文档类型、视图和框架窗口
- 盒子模型
- What is key=lambda in python