网站建设怎么接单,金融网站建设内容,同里做网站,硬件开发外包文章目录 1. 批量插入、检索foreach2. if 判断等于情况3. 模糊查询(pgsql为例)4. 分页5. resultMap 中collection 和association 6. no conflict do update 1. 批量插入、检索foreach
insert idinsertSystemService in… 文章目录 1. 批量插入、检索foreach2. if 判断等于情况3. 模糊查询(pgsql为例)4. 分页5. resultMap 中collection 和association 6. no conflict do update 1. 批量插入、检索foreach
insert idinsertSystemService insert into SYSTEMINFO_SERVICE (system_code, service_id, add_user, add_time)valuesforeach collectionserviceList itemserviceId separator, ( #{systemCode}, #{serviceId}, #{addUser},now()::timestamp(0))/foreach
/insertListInfoBillOwn selectByStates(ListString states);
select idselectByStates resultMapBaseResultMap parameterTypelistselect STOP_OPEN_ID, ACC_NBR, SRV_CODE, STOP_BUSINESS_TYPE, STATE, STATE_DATE, FD_STATUSfrom INF_BILL_OWE where STATE inforeach collectionlist open( close) separator, itemstate#{state}/foreachorder by STOP_OPEN_ID asc
/select2. if 判断等于情况
方式一 if testserviceType0.toString()
/if方式二
if testel.TYPE 1 or el.TYPE 2
,#{el.PARENT_ID}
/if3. 模糊查询(pgsql为例)
方式一 like %${keyword}% //只能用$,不能防止sql注入,且 keyworda’ 会产生报错 方式二 like concat(%,#{keyword,jdbcTypeVARCHAR},%) // 预编译,且 keyworda’ 不会会产生报错 方式三 like %||#{keyword,jdbcTypeVARCHAR} || % // 预编译,且 keyworda’ 不会会产生报错 方式四
if (!StringUtils.isEmpty(keyword)) {keyword % keyword %;
}//外部直接将keyword改为%%like #{keyword,jdbcTypeVARCHAR} // 预编译,且 keyworda’ 不会会产生报错 方式五 bind namepattern2 value% keyword % / xxx like #{pattern2,jdbcTypeVARCHAR} // 预编译,且 keyworda’ 不会会产生报错 4. 分页
字段pageSize,start 如果为integer limit #{pageSize,jdbcTypeINTEGER} offset #{start,jdbcTypeINTEGER} 字段pageSize,start 如果为string limit #{pageSize,jdbcTypeINTEGER}::int offset #{start,jdbcTypeINTEGER}::int 5. resultMap 中collection 和association
resultMap idaaaa typemapresult columntitle_name propertytitle javaTypestring/result columntype propertysubtype javaTypestring/result columncount propertycount javaTypestring/result columnsolve propertysolve javaTypestring/collection propertyitems columntitle_name javaTypecollection ofTypemap notNullColumnitem_idresult columnitem_id propertyitem_id/result columnitem_name propertyitem_name/result columnrn propertyrn//collection
/resultMapresultMap idqryAskDetailsNoDimenMap typemapresult columncategory2_id propertycategory2_id/result columncategory2_name propertycategory2_name/result columnnum propertynum javaTypestring/result columnrn propertyrn javaTypestring/association propertyknowledge columncategory2_id javaTypemapresult propertyknowledge_id columnknowledge_id/result propertyknowledge_solve columnknowledge_solve/result propertyrecommand_num columnrecommand_num javaTypestring/result propertyrelease_time columnrelease_time/result propertysolve_num columnsolve_num javaTypestring/result propertyview_num columnview_num javaTypestring//association/resultMap6. no conflict do update
insert into bs_memo_config (id, xxx, xxx, xxx, xxx, xxxx) VALUES(nextval(seq_xxxx_id),#{editor,jdbcTypeVARCHAR},#{memoId,jdbcTypeVARCHAR},now(),now()) on conflict (username,age)do updateset idbs_memo_staff_config.id,staff_idexcluded.staff_id,xxxxxxexcluded 指的新值,
bs_memo_config.id 指的旧值