First, the MyBatis version must be 3.3.1 and above
The version of the MyBatis that the project relies on must be 3.3.1 and above, the lower version is not, and the version of the jar that ensures that the dependent mybatis of the HAP project needs to be the required version:
Second, @param annotations cannot be used in the DAO layer, and the list variable is used in the Mapper.xml file to receive collections in the DAO layer
Database Library structure Design:
The corresponding DTO layer:
The corresponding Mapper interface:
The corresponding Mapper.xml file:
The specific code below requires the use of annotations to Mycat, which specifies that the insert is for bulk data insertion:
<insert id= "Insertbybatch" >
/*!mycat:catlet=io.mycat.route.sequence.batchinsertsequence * *
Insert into Test_sharding_by_accounting_date (rule_code,name,accounting_date)
Values
<foreach collection= "List" item= "item" index= "index" separator= "," >
(#{item.rulecode,jdbctype=decimal},#{item.name,jdbctype=varchar},#{item.accountingdate,jdbctype=date})
</foreach>
</insert>
Third, Mycat for the Sub-Library table to do the global sequence configuration
Schema.xml file:
The global sequence of the Server.xml file is set to read locally:
Configuration of the Sequence_conf.properties file:
Problem solving: Mycat database middleware +mybatis BULK INSERT data and return all primary key IDs for Row Records