当前位置:首页 > 数据库 > Oracle

Mybatis 针对oracle的批量插入

xml文件参数对象:

            1
            public
            class
             Columns{

            2
            private
             String basedate_code;

            3
            private
             String tableName;

            4
            private
             String codeDescribeindex;

            5
            private
             String codeInfoindex;

            6
            private
             String codePymindex;

            7
            private List<Info> infos;

Dao层方法:

            public
            void bulkInsert(Columns columns);

xml文件配置:

             1
            <
            insert 
            id
            ="bulkInsert"
             parameterType
            ="Columns"
            >
             2
                    insert into manager_basedata_info (app_code,basedata_code,item_code,item_name,item_pym,updatetime)

             3
            <
            foreach 
            collection
            ="infos"
             item
            ="item"
              index
            ="index"
              separator
            ="UNION"
            >
             4
                        select 

             5
                          ‘pc‘,

             6
                           #{basedate_code,jdbcType=VARCHAR},

             7
                           #{item.item_code,jdbcType=VARCHAR},

             8
                           #{item.item_name,jdbcType=VARCHAR},

             9
                           #{item.item_pym,jdbcType=VARCHAR},

            10
                           sysdate 

            11
                           from dual

            12
            </
            foreach
            >
            13
            </
            insert
            >
        

原文:http://www.cnblogs.com/staryy/p/3858768.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!