Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

默认模版遇到的mybatis mapper多参数未识别问题 #107

Open
yegetables opened this issue May 9, 2023 · 0 comments
Open

默认模版遇到的mybatis mapper多参数未识别问题 #107

yegetables opened this issue May 9, 2023 · 0 comments

Comments

@yegetables
Copy link

user表 name,uid,age
生成的Dao是 List<User> queryAllByLimit(User user, @Param("pageable") Pageable pageable);,只有pageable 加了注解。mapper是这样的

<select id="queryAllByLimit" resultMap="UserMap">
        select
          name, uid, age
        from user
        <where>
            <if test="name != null and user.name != ''">
                and name = #{name}
            </if>
            <if test="uid != null">
                and uid = #{uid}
            </if>
            <if test="age != null">
                and age = #{age}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

启动报错org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [pageable, user, param1, param2]

修改模版,List<User> queryAllByLimit(@Param("user") User user, @Param("pageable") Pageable pageable);
更改mapper时添加user.uid/user.name/user.age前缀 解决。

疑问,为什么模版中多参时不全加上@param注解呢?
jdk17 sringboot 3.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant