总之一句话,传递多个参数,要么用Map,要么用Bean
Mapper接口定义
int batchInsert2(@Param("st1")String st1,@Param("st2")String st2,@Param("st3")String st3, @Param("directions") List directions);
int batchInsert1(@Param("st")Station st, @Param("directions") List directions);
int batchInsert(@Param("st")Station st);
public class Station{
private String stationId;
private List directions;
insert into DIRECTION(ID,STATION_ID,DIRECTION_ID,DIRECTION_NAME,DIRECTION_DESC)
select CONCAT(#{st1,jdbcType=VARCHAR},DIRECTION_ID) ID, #{st2,jdbcType=VARCHAR} STATION_ID, DIRECTION_ID,CODEDESC DIRECTION_NAME,CODEDESC DIRECTION_DESC from(
select #{item.directionId,jdbcType=VARCHAR} DIRECTION_ID
)a,t_sys_code b
where a.DIRECTION_ID = b.CODE
and a.DIRECTION_ID not in(select DIRECTION_ID from DIRECTION where STATION_ID = #{st3,jdbcType=VARCHAR})
insert into DIRECTION(ID,STATION_ID,DIRECTION_ID,DIRECTION_NAME,DIRECTION_DESC)
select CONCAT(#{st.stationId,jdbcType=VARCHAR},DIRECTION_ID) ID, #{st.stationId,jdbcType=VARCHAR} STATION_ID, DIRECTION_ID,CODEDESC DIRECTION_NAME,CODEDESC DIRECTION_DESC from(
select #{item.directionId,jdbcType=VARCHAR} DIRECTION_ID
)a,t_sys_code b
where a.DIRECTION_ID = b.CODE
and a.DIRECTION_ID not in(select DIRECTION_ID from DIRECTION where STATION_ID = #{st.stationId,jdbcType=VARCHAR})
insert into DIRECTION(ID,STATION_ID,DIRECTION_ID,DIRECTION_NAME,DIRECTION_DESC)
select CONCAT(#{st.stationId,jdbcType=VARCHAR},DIRECTION_ID) ID, #{st.stationId,jdbcType=VARCHAR} STATION_ID, DIRECTION_ID,CODEDESC DIRECTION_NAME,CODEDESC DIRECTION_DESC from(
select #{item.directionId,jdbcType=VARCHAR} DIRECTION_ID
)a,t_sys_code b
where a.DIRECTION_ID = b.CODE
and a.DIRECTION_ID not in(select DIRECTION_ID from DIRECTION where STATION_ID = #{st.stationId,jdbcType=VARCHAR})
于是方法2,尝试使用Station类型的变量,在SQL中需要使用#{参数名.属性名}
进而方法2中,List变量是使用 “参数名.属性名” 的方式来引用
------------------------------------------------------------------------------------------------------
看看之间的定义,另做参考
insert into auth_menu (menu_id,authority_id)
values
(#{authId,jdbcType=INTEGER},#{menuId})