zoukankan      html  css  js  c++  java
  • springboot报错_必须为元素类型 "insert" 声明属性 "resultMap"的解决

    一、问题

    报错:必须为元素类型 "insert" 声明属性 "resultMap"的解决。

    代码:

            <resultMap id="result" type="com.example.demo.bean.Node">
    		<result property="nodeID" column="nodeID" />
    		<result property="nodeType" column="nodeType" />
    		<result property="relation" column="relation" />
    	</resultMap>
     
    	<insert id="addNode" parameterType="com.example.demo.bean.Node"
    		keyProperty="nodeID" useGeneratedKeys="true" resultMap="java.lang.Integer">
    		INSERT INTO tb_nodetree
    		(
    		nodeId,nodeType,relation
    		)
    		VALUES (
    		#{nodeId},#{nodeType},#{relation}
    		)
    	</insert>    
    

    2.原因

    因为接口中想返回一个整数来查看是否添加进数据库,所以在insert方法中加了resultMap属性,结果就出错了。

    3.解决

    把insert中的resultMap删掉就行了,仍然会返回整数(数据库受影响的行数)。

  • 相关阅读:
    省选知识点
    寒假练习
    水题欢乐赛-套路
    2019年12月(2)
    洛谷P1347 排序
    Aizu
    2019年12月(1)
    【CSP2019】
    联系博主
    UVA1420 Priest John's Busiest Day【贪心】
  • 原文地址:https://www.cnblogs.com/smxbo/p/13160466.html
Copyright © 2011-2022 走看看