Freemarker list的使用
更新多条记录的操作,这里ids是一个数组
<sqltemplate id = "disableBuildLabourer"> <![CDATA[ UPDATE build_labourer SET status = 0 WHERE id IN ( <#list ids as num> ${num} <#if num_has_next>,</#if> </#list> ) ]]> </sqltemplate>
插入多条记录的操作,这里buildLabourerList是一个List<BuildLabourer>的集合
<sqltemplate id="batchImportBuildLabourer"> <![CDATA[ INSERT INTO build_labourer ( realname, sex, id_card, work_type, nation, address, phone )VALUES <#list buildLabourerList as buildLabourer> ( '${buildLabourer.realname}', '${buildLabourer.sex}', '${buildLabourer.idCard}', '${buildLabourer.workType}', '${buildLabourer.nation}', '${buildLabourer.address}', '${buildLabourer.phone}' ) <#if buildLabourer_has_next>,</#if> </#list> ]]> </sqltemplate>
作者:Rest探路者
出处:http://www.cnblogs.com/Java-Starter/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意请保留此段声明,请在文章页面明显位置给出原文连接
Github:https://github.com/cjy513203427