springboot中怎么实现通过后台创建临时表
导读:本文共1224.5字符,通常情况下阅读需要4分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: springboot 如何通过后台创建临时表其实创建临时表,跟增删改查的原理是一样的,只不过是在xml中写一个创建临时表sql语句,xml中并不是只能写增删改查语句的1,首先弄一个xml在xml中写一个修改头标签,因为是建立的是临时表,所以表名要变,需要在表名处接收一个参数$(tableName) ,这时xml文件就写好了2,在mapper中写出对应方法这时需要... ...
音频解说
目录
(为您整理了一些要点),点击可以直达。springboot 如何通过后台创建临时表
其实创建临时表,跟增删改查的原理是一样的,只不过是在xml中写一个创建临时表sql语句,xml中并不是只能写增删改查语句的
1,首先弄一个xml
在xml中写一个修改头标签,因为是建立的是临时表,所以表名要变,需要在表名处接收一个参数$(tableName) ,这时xml文件就写好了
2,在mapper中写出对应方法
这时需要在参数中加上注解@Param,只有加上这个注解,在xml中才可以接收到我传入的参数
3,接下来在service层和Controller层中调用这个方法
然后在postman中传入需要的表名,就可以生成这个表了。
springboot mybatis下临时表的创建和删除,可用于查重去重
/***创建临时表*/@Update({"droptemporarytableifexists${tableName};","createtemporarytable${tableName}selectdoctor_idfromcrm_speakerwhere1=2"})voidcreateTemoraryTable(@Param("tableName")StringtableName);/***保存数据到临时表里面以便校验数据重复*/@Insert("<script>"+"insertinto${tableName}(doctor_id)values"+"<foreachcollection="list"item="doct"index="index"separator=",">"+"("+"#{doct.doctorId,jdbcType=VARCHAR}"+")"+"</foreach>"+"</script>")voidinsertBatchCheckDatas(@Param("list")List<SpeakerDO>dOs,@Param("tableName")StringtableName);/***删除临时表*/@Update({"droptemporarytableifexists${tableName}"})voiddropTemporaryTable(@Param("tableName")StringtableName);
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:
springboot中怎么实现通过后台创建临时表的详细内容,希望对您有所帮助,信息来源于网络。