Giter Site home page Giter Site logo

Comments (29)

qmdx avatar qmdx commented on May 6, 2024 21

@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.

SHDNMD avatar SHDNMD commented on May 6, 2024 13

老大哥现在mybatisPlus已经3.+了请问支持连表查询了吗

from mybatis-plus.

whiletrue2009 avatar whiletrue2009 commented on May 6, 2024 7

看了下,已经有v2.0.8了,可以支持了吗?

from mybatis-plus.

yangyang0507 avatar yangyang0507 commented on May 6, 2024 2

抱歉,暂不支持多表关联,目前的多表操作请按照传统Mybatis一样写xml、mapper和service。 我们计划在2.0中支持,请期待2.0版本~

from mybatis-plus.

idlesysman avatar idlesysman commented on May 6, 2024 2

@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.

CoderPoet avatar CoderPoet commented on May 6, 2024 1

${ew.sqlSegment}
这个${ew.sqlSegment} 是不是前面少了个WHERE

from mybatis-plus.

pluveto avatar pluveto commented on May 6, 2024 1

习惯了orm关联查询,感觉手写sql好多硬编码

from mybatis-plus.

luobeichen avatar luobeichen commented on May 6, 2024 1

所以现在还是得手撕多表吗?

from mybatis-plus.

whiletrue2009 avatar whiletrue2009 commented on May 6, 2024

这个问题比较大啊,期待早日实现

from mybatis-plus.

lewlh avatar lewlh commented on May 6, 2024

我也没找到对于联表查询的支持方法

from mybatis-plus.

lewlh avatar lewlh commented on May 6, 2024

@qmdx 明白了。

from mybatis-plus.

zhangshaoru avatar zhangshaoru commented on May 6, 2024

问下现在支持联表查询了 么

from mybatis-plus.

Qianlu5110 avatar Qianlu5110 commented on May 6, 2024

@qmdx 我参考你的DEMO 试了一下,只能添加 left join 表 on 字句1 and 字句2。怎样支持left join 表 on 字句1 and 字句2 where 字句3 and 字句4

from mybatis-plus.

stormMayo avatar stormMayo commented on May 6, 2024

现在支持联表查询了 么

from mybatis-plus.

dwarfzebra avatar dwarfzebra commented on May 6, 2024

多表关联时遇到了一个问题,我在实体类字段上使用@TableField定义了别名,如果使用xml和注解的形式去写多表关联 我需要把每个字段再显示的起别名 才能够注入到实体类中 字段少时还可以,字段多了很不方便 而且以后维护起来也不舒服。有没有猿可以写一个扩展,就是可以让我的多表关联sql里查询出来的字段可以直接被实体类字段上注解识别 这样我的别名就可以都写在一个地方了 -- 感觉很有用处

from mybatis-plus.

qmdx avatar qmdx commented on May 6, 2024

@SHDNMD xml 中去做,mp 暂无注解支持计划

from mybatis-plus.

SHDNMD avatar SHDNMD commented on May 6, 2024

from mybatis-plus.

happyyangyuan avatar happyyangyuan commented on May 6, 2024

近期基于mybatis-plus扩展写了个基于注解的多表关联查询功能,新增了5个注解,支持单主键场景下的一对多、多对多多表关联查询功能。
大言不惭,不知道baomidou的大佬是否有意愿合并PR,如果有意愿的话,我春节后我可以开始着手准备跟mybatis-plus做一些融合开发。

from mybatis-plus.

miemieYaho avatar miemieYaho commented on May 6, 2024

不会支持

from mybatis-plus.

happyyangyuan avatar happyyangyuan commented on May 6, 2024

不会支持
好的,了解啦。

from mybatis-plus.

1981795167 avatar 1981795167 commented on May 6, 2024

为啥不支持

from mybatis-plus.

viqbgrg avatar viqbgrg commented on May 6, 2024

@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.

senlinyang avatar senlinyang commented on May 6, 2024

mybatis-plus的确还不可以做多表查询,多表还是需要自己手动去写SQL的,不过之前我用过Diboot自动生成代码的工具,关于多表查询的话只需要适当的注释就可以了,感觉还是挺方便的,你们如果不想写SQL的话,可以去了解一下。下面的是链接:
https://www.diboot.com/

from mybatis-plus.

senlinyang avatar senlinyang commented on May 6, 2024

mybatis-plus确实可以做多表,多表还是需要自己手动去写SQL的,不过我之前用过Diboot自动生成代码的工具,关于多表查询的话只需要适当的注释就可以了,感觉还是挺方便的,你们如果不想写SQL的话,可以去了解一下。下面是链接:https ://www.diboot.com/

用着应该还可以,你们可以试一下

from mybatis-plus.

uucoding avatar uucoding commented on May 6, 2024

所以现在还是得手撕多表吗?

diboot了解一下啊,基于MP,支持多表关联哎

from mybatis-plus.

senlinyang avatar senlinyang commented on May 6, 2024

from mybatis-plus.

amberfan avatar amberfan commented on May 6, 2024

求支持啊,写字段别名实在是不爽啊

from mybatis-plus.

JamesSmith888 avatar JamesSmith888 commented on May 6, 2024

也就东亚人喜欢用mybatis了,大部分都还是chinese

from mybatis-plus.

SleepySoSleep avatar SleepySoSleep commented on May 6, 2024

只有"ew"有效的

from mybatis-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.