How can I pass multiple parameters and use them?

前端 未结 3 1920
执笔经年
执笔经年 2021-02-07 05:41

Hi I\'m new to myBatis.

I\'m using MyBatis and Spring with mybatis-spring.

How can I pass two different types of objects as parameters, and how can I use their p

3条回答
  •  死守一世寂寞
    2021-02-07 06:29

    Use parameterType="map" and @Param annotation.

    Method declared in interface:

    void mapCategoryAndPage(@Param("categoryLocalId") Long categoryLocalId, @Param("pageLocalId") Long localId);
    

    It is not required that value of @Param annotation must be equal to name of parameter

    
        INSERT INTO
            category_page_mapping (
                page_local_id,
                category_local_id)
        VALUES
            (#{pageLocalId},
             #{categoryLocalId});
    
    

提交回复
热议问题