Comments (29)
@whiletrue2009 @SZJZ 多表 MP 不会支持,不然就变成 Hibernate 了失去了 mybatis 原有自定义 SQL 灵活性的优势,最佳实践如下:
List<OrderVerify> findByWrapper(@Param("ew") Wrapper wrapper);
<select id="findGymnasiumOrderVerify" resultType="OrderVerify">
SELECT o.id AS orderId, o.order_no AS orderNo, ... FROM order o
LEFT JOIN category c ON o.category_id=c.id
${ew.sqlSegment}
</select>
from mybatis-plus.
老大哥现在mybatisPlus已经3.+了请问支持连表查询了吗
from mybatis-plus.
看了下,已经有v2.0.8了,可以支持了吗?
from mybatis-plus.
抱歉,暂不支持多表关联,目前的多表操作请按照传统Mybatis一样写xml、mapper和service。 我们计划在2.0中支持,请期待2.0版本~
from mybatis-plus.
@qmdx 我参考你的DEMO 试了一下,只能添加 left join 表 on 字句1 and 字句2。怎样支持left join 表 on 字句1 and 字句2 where 字句3 and 字句4
你可传多个Wrapper,然后用
List<OrderVerify> findByWrapper(@Param("ew1") Wrapper wrapper,@Param("ew2") Wrapper wrapper);
select * from
(select *** from a where 1=1 ${ew1.sqlSegment}) a
left join
(select **** from b where 1=1 ${ew2.sqlSegment} ) b
on a.xx=b.xx
from mybatis-plus.
${ew.sqlSegment}
这个${ew.sqlSegment} 是不是前面少了个WHERE
from mybatis-plus.
习惯了orm关联查询,感觉手写sql好多硬编码
from mybatis-plus.
所以现在还是得手撕多表吗?
from mybatis-plus.
这个问题比较大啊,期待早日实现
from mybatis-plus.
我也没找到对于联表查询的支持方法
from mybatis-plus.
@qmdx 明白了。
from mybatis-plus.
问下现在支持联表查询了 么
from mybatis-plus.
@qmdx 我参考你的DEMO 试了一下,只能添加 left join 表 on 字句1 and 字句2。怎样支持left join 表 on 字句1 and 字句2 where 字句3 and 字句4
from mybatis-plus.
现在支持联表查询了 么
from mybatis-plus.
多表关联时遇到了一个问题,我在实体类字段上使用@TableField定义了别名,如果使用xml和注解的形式去写多表关联 我需要把每个字段再显示的起别名 才能够注入到实体类中 字段少时还可以,字段多了很不方便 而且以后维护起来也不舒服。有没有猿可以写一个扩展,就是可以让我的多表关联sql里查询出来的字段可以直接被实体类字段上注解识别 这样我的别名就可以都写在一个地方了 -- 感觉很有用处
from mybatis-plus.
@SHDNMD xml 中去做,mp 暂无注解支持计划
from mybatis-plus.
from mybatis-plus.
近期基于mybatis-plus扩展写了个基于注解的多表关联查询功能,新增了5个注解,支持单主键场景下的一对多、多对多多表关联查询功能。
大言不惭,不知道baomidou的大佬是否有意愿合并PR,如果有意愿的话,我春节后我可以开始着手准备跟mybatis-plus做一些融合开发。
from mybatis-plus.
不会支持
from mybatis-plus.
不会支持
好的,了解啦。
from mybatis-plus.
为啥不支持
from mybatis-plus.
@qmdx 我参考你的DEMO 试了一下,只能添加 left join 表 on 字句1 and 字句2。怎样支持left join 表 on 字句1 and 字句2 where 字句3 and 字句4
你可传多个Wrapper,然后用
List<OrderVerify> findByWrapper(@Param("ew1") Wrapper wrapper,@Param("ew2") Wrapper wrapper);select * from (select *** from a where 1=1 ${ew1.sqlSegment}) a left join (select **** from b where 1=1 ${ew2.sqlSegment} ) b on a.xx=b.xx
这个好像只支持ew这一个参数
from mybatis-plus.
mybatis-plus的确还不可以做多表查询,多表还是需要自己手动去写SQL的,不过之前我用过Diboot自动生成代码的工具,关于多表查询的话只需要适当的注释就可以了,感觉还是挺方便的,你们如果不想写SQL的话,可以去了解一下。下面的是链接:
https://www.diboot.com/
from mybatis-plus.
mybatis-plus确实可以做多表,多表还是需要自己手动去写SQL的,不过我之前用过Diboot自动生成代码的工具,关于多表查询的话只需要适当的注释就可以了,感觉还是挺方便的,你们如果不想写SQL的话,可以去了解一下。下面是链接:https ://www.diboot.com/
用着应该还可以,你们可以试一下
from mybatis-plus.
所以现在还是得手撕多表吗?
diboot了解一下啊,基于MP,支持多表关联哎
from mybatis-plus.
from mybatis-plus.
求支持啊,写字段别名实在是不爽啊
from mybatis-plus.
也就东亚人喜欢用mybatis了,大部分都还是chinese
from mybatis-plus.
只有"ew"有效的
from mybatis-plus.
Related Issues (20)
- 请问一下,您这个mybatis plus最新版本还没有支持双重主键吗? HOT 1
- V3.5.6新增接口存在问题 HOT 3
- V3.5.6 新增 IJsonTypeHandler 的toJson方法传入的不是T,而是Object
- @EnumValue枚举使用出错 HOT 1
- 有考虑增加联合主键、多表join的功能开发计划么 HOT 1
- 能否在QueryWrapper和LambdaQueryWrapper中也增加Page.addOrder那样直接传OrderItem的方法
- BaseMapper#updateById会将字段更新为null HOT 4
- 文档打不开,浏览器调试窗口console报错 HOT 1
- 关于disable模版生成失效 HOT 5
- 升级到3.5.6执行sql提示无此方法Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: net.sf.jsqlparser.statement.select.Select.getSelectBody() HOT 1
- mybatis-plus-boot-starter:3.1.1升级到mybatis-plus-spring-boot3-starter:3.5.4 save 不自动清空主键内容 HOT 1
- 支持一个Mapper绑定多个XML的功能 HOT 4
- 3.3.1版本针对数据表字段做映射时,如果字段第一个前缀只有一个字母,无法转成正常的驼峰命名格式 HOT 2
- springjpa+junit5+mockito+querydsl HOT 1
- 继承 BaseMapper 类能否在xml层重写其中方法,后续调用方法能够执行重写方法, HOT 5
- 在继承ServiceImpl的实现类中自动注入失效 HOT 4
- An error occurred while adding a service to the nacos registry using dubbo3 HOT 1
- 翻页插件问题 HOT 1
- An error occurred while adding a service to the nacos registry using dubbo3 HOT 1
- 对 #5745 的优化导致分页查询中如包含distinct跟orderby会导致sqlserver语法错误 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mybatis-plus.