关于mybatis多表查询自定义sql的简单使用

194 阅读21分钟

如果你想查多表,但是不想配置映射怎么办,教大家一种简单方便的方法

接口返回参数类型为List<Map<String, Object>>,mapping配置为resultType="java.util.Map"

然后返回的参数就是多个map对象了。

接口:

List<Map<String, Object>> selectBoxshotMyList(@Param("dataScope") DataScope dataScope, @Param("ew" Wrapper<PickingDetail> wrapper);

mapping:

<select id="selectBoxshotMyList" resultType="java.util.Map">
    SELECT p.*,b.startTime,b.endTime from 
    picking_detail p LEFT JOIN box_shot_code b on p.orderId=b.orderId    
<where>        
    ${ew.sqlSegment}    
</where>
</select>

使用: