mybatis封装多个参数的方法总结

1 单个参数

 

select name from test

where id=#{id}

 

2 多个参数之map

 

select name from test

where id=#{id} and flag=#{flag}

 

3 多个参数之bean

 

select name from test

where id=#{id} and flag=#{flag}

 

4 多个参数之list

  

        select name from testwhere Id in  

        

            open="(" close=")" separator="," item="item" index="index">  

            #{item.id}  

          

    

批量插入

SELECT

LAST_INSERT_ID()

insert into test (name,time,flag)

values

(#{item.name},#{item.time},#{item.flag})

5 多个参数之数组

  

        select name from testwhere Id in  

        

            open="(" close=")" separator="," item="item" index="index">  

            #{item.id}  

          

    

你可能感兴趣的:(SSM)