MyBatis Batch Insert: Fixing 'Parameter 'knowledgeId' not found' Error
This error occurs because the parameter 'knowledgeId' is not found in the given batch insert statement. The available parameters are 'entities' and 'param1'.
To fix this issue, you need to remove the condition for 'knowledgeId' in the first
Here's the modified code:
<insert id="insertBatch" keyColumn="knowledge_id" keyProperty="knowledgeId" useGeneratedKeys="true">
insert into knowledge_base_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="knowledgeTitle != null and knowledgeTitle != ''">knowledge_title,</if>
<if test="knowledgeAnswer != null and knowledgeAnswer != ''">knowledge_answer,</if>
<if test="labelId != null">label_id,</if>
<if test="commodityName != null and commodityName != ''">commodity_name,</if>
<if test="commodityCode != null and commodityCode != ''">commodity_code,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="remarks != null and remarks != ''">remarks,</if>
<if test="deleteFlag != null">delete_flag,</if>
</trim>
<foreach collection="entities" item="entity" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="knowledgeTitle != null and knowledgeTitle != ''">#{entity.knowledgeTitle,jdbcType=VARCHAR},</if>
<if test="knowledgeAnswer != null and knowledgeAnswer != ''">#{entity.knowledgeAnswer,jdbcType=VARCHAR},</if>
<if test="labelId != null">#{entity.labelId,jdbcType=INTEGER},</if>
<if test="commodityName != null and commodityName != ''">#{entity.commodityName,jdbcType=VARCHAR},</if>
<if test="commodityCode != null and commodityCode != ''">#{entity.commodityCode,jdbcType=VARCHAR},</if>
<if test="createBy != null and createBy != ''">#{entity.createBy,jdbcType=VARCHAR},</if>
<if test="createTime != null">#{entity.createTime,jdbcType=TIMESTAMP},</if>
<if test="remarks != null and remarks != ''">#{entity.remarks,jdbcType=VARCHAR},</if>
<if test="deleteFlag != null">#{entity.deleteFlag,jdbcType=INTEGER},</if>
</trim>
</foreach>
</insert>
In this modified code, the 'knowledgeId' parameter is removed from both the
原文地址: https://www.cveoy.top/t/topic/pmqW 著作权归作者所有。请勿转载和采集!