本人项目使用baomidou的mybatis-plus

mapper是否支持方法重载,还是有待考证。因为同样的代码,似乎昨天没问题,今天不行了。

首先是mapper定义了两个方法重载,

    @Select(" select id,custom_group_id,custom_group_name,custom_group_parent_id from sys_device_group " +
            "where custom_group_id = #{customGroupId}")
    DeviceGroupEntity selectByCustomGroupId(@Param("customGroupId") String customGroupId);

    @Select("<script>select id,custom_group_id,custom_group_name,custom_group_parent_id from sys_device_group " +
            "where custom_group_id = #{customGroupId} <if test='appId != null'> and app_id = #{appId}</if></script>")
    DeviceGroupEntity selectByCustomGroupIdAppId(@Param("customGroupId") String customGroupId, @Param("appId") Long appId);

具体的使用:

    public DeviceGroupEntity selectByCustomGroupIdAppId(String customGroupId, Long appId) {
        log.info("updateDeviceGroup.4444444.appId:{}", appId);

        return baseMapper.selectByCustomGroupIdAppId(customGroupId, appId);
    }

重启了几次应用服务器,结构还是一直调用带有一个参数的方法,迫不得己把方法名字改了。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐