mybatis注解批量插入、更新

mybatis注解批量插入、更新需求在进行入库时,数据一条条入库时间太慢了,批量入库速度更快批量插入这里使用注解的方法@Insert进行数据插入@Insert(“<script>”+”insertintocommunityinfo(tguid,CityName,District,ResidentialAreaName,ResidentialAreaAlias,School,Description,NearbySchool,SupportFacility,RingRoad,Manag

大家好,欢迎来到IT知识分享网。

需求

在进行入库时,数据一条条入库时间太慢了,批量入库速度更快

批量插入

这里使用注解的方法@Insert进行数据插入

@Insert("<script> " +
            "insert into communityinfo (tguid,CityName,District,ResidentialAreaName,ResidentialAreaAlias,School,Description,NearbySchool,SupportFacility,RingRoad,ManagementCompany,GreeningRate,ManagementFees,ManagementFeesDesp,BaseFacility,Network,PublicSecurity,CarsAmount,ParkingRatio,Parking,BuildingCategory,HouseTypes,HouseType,EndJobDate,CompletionDate,SellDate,LandUseYearsLimit,DeveloperCompany,BuildingStructure,BuildingArea,LandArea,HousingCount,HouseBuildingCount,FloorAreaRatio) VALUES " +
            "<foreach collection=\"list\" item=\"community\" index=\"index\" separator=\",\"> " +
            "(#{community.tguid},#{community.CityName},#{community.District},#{community.ResidentialAreaName},#{community.ResidentialAreaAlias},#{community.School},#{community.Description},#{community.NearbySchool},#{community.SupportFacility},#{community.RingRoad},#{community.ManagementCompany},#{community.GreeningRate},#{community.ManagementFees},#{community.ManagementFeesDesp},#{community.BaseFacility},#{community.Network},#{community.PublicSecurity},#{community.CarsAmount},#{community.ParkingRatio},#{community.Parking},#{community.BuildingCategory},#{community.HouseTypes},#{community.HouseType},#{community.EndJobDate},#{community.CompletionDate},#{community.SellDate},#{community.LandUseYearsLimit},#{community.DeveloperCompany},#{community.BuildingStructure},#{community.BuildingArea},#{community.LandArea},#{community.HousingCount},#{community.HouseBuildingCount},#{community.FloorAreaRatio}) " +
            "</foreach> " +
            "</script>")
    boolean insertBatch(List<Community> list);

批量更新

@Update({ 
   
            "<script>",
            "<foreach collection='list' item='item' index='index' separator=';'>",
            "update communityinfo b",
            "set b.DistrictName= #{item.DistrictName} where b.id= #{item.id}",
            "</foreach>",
            "</script>"
    })
    boolean batchUpdateName(@Param(value="list")List<Community_copy> list);

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/10970.html

(0)

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信