In fact, creating a temporary table is the same as the principle of adding, deleting, modifying, and querying. It is just writing a create temporary table sql statement in xml. There is not only If you can write add, delete, modify, query statements,
and write a modification header tag in the xml. Because a temporary table is created, the table name needs to be changed. The table name receives a parameter $(tableName). At this time, the xml file is written
This When you need to add the annotation @Param to the parameter, only by adding this annotation can you receive the parameters I passed in in xml
in the layer and Controller layer and then pass in the required table name in postman to generate this table.
/** * 创建临时表 */ @Update({"drop temporary table if exists ${tableName};", "create temporary table ${tableName} select doctor_id from crm_speaker where 1=2 "}) void createTemoraryTable(@Param("tableName") String tableName); /** * 保存数据到临时表里面以便校验数据重复 */ @Insert("<script>" + "insert into ${tableName} (doctor_id) values " + " <foreach collection="list" item="doct" index="index" separator=","> " + " (" + " #{doct.doctorId,jdbcType=VARCHAR} " + " ) " + " </foreach> " + "</script>") void insertBatchCheckDatas(@Param("list") List<SpeakerDO> dOs, @Param("tableName") String tableName); /** * 删除临时表 */ @Update({"drop temporary table if exists ${tableName}"}) void dropTemporaryTable(@Param("tableName") String tableName);
The above is the detailed content of How to create a temporary table through the background in springboot. For more information, please follow other related articles on the PHP Chinese website!