闲幻 2023-06-18 10:59 采纳率: 0%
浏览 21

idea后端报错,语句可能存在语法错误。需要检查 Mapper 文件和 SQL 查询语句是否正确,并确保正确加载相关文件。

后端报错

img

ProductMapper.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mail_1.mail.mapper.ProductMapper">

    <resultMap id="productResult" type="com.mail_1.mail.entity.Product">
        <association property="type" column="typeId" select="com.mail_1.mail.mapper.SmallTypeMapper.findById"></association>
    </resultMap>

    <select id="list" parameterType="Map" resultMap="productResult">
        select * from product
        <where>
            <if test="name!=null and name!='' ">
                and name like concat('%',#{name},'%')
            </if>
        </where>
        <if test="start!=null and pageSize!=null ">
            limit #{start},#{pageSize}
        </if>
    </select>

    <select id="getTotal" parameterType="Map" resultType="Long">
        select count(*) from product
        <where>
            <if test="name!=null and name!='' ">
                and name like concat('%',#{name},'%')
            </if>
        </where>
    </select>

    <insert id="add" parameterType="com.mail_1.mail.entity.Product">
        insert into product values(null,#{name},#{price},#{stock},#{proPic},#{hot},#{swiper},#{swiperPic},#{swiperSort},#{type.id},null,#{productIntroImgs},#{productParaImgs},#{description});
    </insert>

    <update id="update" parameterType="com.mail_1.mail.entity.Product">
        update product
        <set>
            <if test="name!=null and name!=''">
                name=#{name},
            </if>
            <if test="price!=null">
                price=#{price},
                price=#{price},
            </if>
            <if test="stock!=null">
                stock=#{stock},
            </if>
            <if test="type!=null and type.id!=null">
                typeId=#{type.id},
            </if>
            <if test="proPic!=null and proPic!=''">
                proPic=#{proPic},
            </if>
            <if test="description!=null and description!=''">
                description=#{description},
            </if>
            <if test="productIntroImgs!=null and productIntroImgs!=''">
                productIntroImgs=#{productIntroImgs},
            </if>
            <if test="productParaImgs!=null and productParaImgs!=''">
                productParaImgs=#{productParaImgs},
            </if>
            <if test="swiperPic!=null and swiperPic!=''">
                swiperPic=#{swiperPic},
            </if>
            <if test="swiperSort!=null">
                swiperSort=#{swiperSort},
            </if>
        </set>
        where id=#{id}
    </update>

    <select id="findById" parameterType="Integer" resultMap="productResult">
        select * from product where id=#{id}
    </select>

</mapper>

  • 写回答

2条回答 默认 最新

  • 心寒丶 全栈领域优质创作者 2023-06-18 11:31
    关注

    你这里不是返回一个SmallType 么,

    img


    mapper中返回的是这个?

    img

    img

    评论

报告相同问题?

问题事件

  • 创建了问题 6月18日

悬赏问题

  • ¥15 c#转安卓 java html
  • ¥15 os.listdir文件路径找不到
  • ¥15 使用gojs3.0,如何在nodeDataArray设置好text的位置,再go.TextBlock alignment中进行相应的改变
  • ¥15 psfusion图像融合指标很低
  • ¥15 银河麒麟linux系统如何修改/etc/hosts权限为777
  • ¥50 医院HIS系统代码、逻辑学习
  • ¥30 docker离线安装mysql报错,如何解决?
  • ¥15 构建工单的总账影响在哪里查询或修改
  • ¥15 三个简单项目写完之后有重赏之后联系我
  • ¥15 python报内存不能read错误