这是我的包装纸。
QueryWrapper<Tag> tagQueryWrapper = Wrappers.<Tag>query()
.select("name", "count(*) num")
.groupBy("name")
.orderByDesc("num");这是我的地图。
@Component
public interface TagMapper extends BaseMapper<Tag> {
@Select("select * from tag left join blog_tag bt on tag.id = bt.tag_id ${ew.customSqlSegment}")
List<Tag> selectNameNum(IPage<Tag> page, @Param(Constants.WRAPPER) Wrapper<Tag> queryWrapper);
}我不知道为什么这个‘select(列.’不工作。它生成的SQL语句如下:
select * from tag left join blog_tag bt on tag.id = bt.tag_id GROUP BY name ORDER BY num DESC LIMIT ?,?
请帮帮我,我想知道如何用select(列.)替换SQL语句中的'*‘
发布于 2019-11-26 17:19:15
考虑到Constants.WRAPPER是ew,您可以在Wrapper中使用另一个getter来获得选择列列表(类似于已经获得customSqlSegment的方式),如下所示:
@Component
public interface TagMapper extends BaseMapper<Tag> {
@Select("select ${ew.sqlSelect} from tag left join blog_tag bt on tag.id = bt.tag_id ${ew.customSqlSegment}")
List<Tag> selectNameNum(IPage<Tag> page, @Param(Constants.WRAPPER) Wrapper<Tag> queryWrapper);
}https://stackoverflow.com/questions/59054031
复制相似问题