报错`Message.xml中报错`

来源:3-2 SQL 基本配置与执行

qq_Disorganized_04359428

2017-02-09 14:46

http://img.mukewang.com/589c0ff90001391309770229.jpg

错误内容 Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserAlias'.  Cause: java.lang.ClassNotFoundException: Cannot find class: UserAlias


<mapper namespace="Message">

  <!-- type对应的哪个实体类,id要在resultMap中唯一  -->

  <resultMap type="bean.Message" id="MessageResult">

    <!-- 数据库中主键用ID标签  -->

    <!-- column对应数据库中的字段名,property对应了实体类中的属性名 ,jdbcType对应了数据库中的属性类型-->

    <id column="ID" jdbcType="INTEGER" property="id"/>

    <!-- 数据库中普通字段用result标签 -->

    <result column="COMMAND" jdbcType="VARCHAR" property="command"/>

    <result column="DESCRIPTION" jdbcType="VARCHAR" property="description"/>

    <result column="CONTENT" jdbcType="VARCHAR" property="content"/>

  </resultMap>

 <!-- Mybatis中的配置信息,应用在一条具体的SQL语句上,通过resultMap标签指向相对应的id名  -->

  <select id="queryMessageList" resultMap="MessageResult">

    select ID,COMMAND,DESCRIPTION,CONTENT from message where 1=1

  </select>


  <select id="version" parameterType="long" resultType="int">

    SELECT version FROM user WHERE id = #{id,jdbcType=INTEGER}

  </select>


  <delete id="delete" parameterType="UserAlias">

    DELETE FROM user WHERE id = #{id:INTEGER}

  </delete>


  <insert id="insert" parameterType="UserAlias" useGeneratedKeys="false">

    INSERT INTO user

    ( id,

    username,

    password,

    administrator

    )

    VALUES

    ( #{id},

    #{username,jdbcType=VARCHAR},

    #{password.encrypted:VARCHAR},

    #{administrator,jdbcType=BOOLEAN}

    )

  </insert>


  <update id="update" parameterType="UserAlias">

    UPDATE user SET

    username = #{username,jdbcType=VARCHAR},

    password = #{password.encrypted,jdbcType=VARCHAR},

    administrator = #{administrator,jdbcType=BOOLEAN}

    WHERE

    id = #{id,jdbcType=INTEGER}

  </update>


  <!--   Unique constraint check -->

  <select id="isUniqueUsername" parameterType="map" resultType="boolean">

    SELECT (count(*) = 0)

    FROM user

    WHERE ((#{userId,jdbcType=BIGINT} IS NOT NULL AND id != #{userId,jdbcType=BIGINT}) OR #{userId,jdbcType=BIGINT} IS

    NULL)  <!-- other than me -->

    AND (username = #{username,jdbcType=VARCHAR})

  </select>

</mapper>



查看了下`是下面的删除和插入等``parameterType="UserAlias"报找不到``如何处理?删掉下面的SQL语句么?

写回答 关注

2回答

  • 你猜我猜不猜你猜1
    2017-03-20 12:28:13

    把你的这个删除就可以了!

    <select id="version" parameterType="long" resultType="int">

        SELECT version FROM user WHERE id = #{id,jdbcType=INTEGER}

      </select>


      <delete id="delete" parameterType="UserAlias">

        DELETE FROM user WHERE id = #{id:INTEGER}

      </delete>


      <insert id="insert" parameterType="UserAlias" useGeneratedKeys="false">

        INSERT INTO user

        ( id,

        username,

        password,

        administrator

        )

        VALUES

        ( #{id},

        #{username,jdbcType=VARCHAR},

        #{password.encrypted:VARCHAR},

        #{administrator,jdbcType=BOOLEAN}

        )

      </insert>


      <update id="update" parameterType="UserAlias">

        UPDATE user SET

        username = #{username,jdbcType=VARCHAR},

        password = #{password.encrypted,jdbcType=VARCHAR},

        administrator = #{administrator,jdbcType=BOOLEAN}

        WHERE

        id = #{id,jdbcType=INTEGER}

      </update>


      <!--   Unique constraint check -->

      <select id="isUniqueUsername" parameterType="map" resultType="boolean">

        SELECT (count(*) = 0)

        FROM user

        WHERE ((#{userId,jdbcType=BIGINT} IS NOT NULL AND id != #{userId,jdbcType=BIGINT}) OR #{userId,jdbcType=BIGINT} IS

        NULL)  <!-- other than me -->

        AND (username = #{username,jdbcType=VARCHAR})

      </select>


  • qq_太阳火_0
    2017-02-09 15:34:46

    删除 

    <!-- Mybatis中的配置信息,应用在一条具体的SQL语句上,通过resultMap标签指向相对应的id名  -->

      <select id="queryMessageList" resultMap="MessageResult">

        select ID,COMMAND,DESCRIPTION,CONTENT from message where 1=1

      </select>

    之后的sql语句

通过自动回复机器人学Mybatis---基础版

微信公众号自动回复功能学习Mybatis,基础教程加案例实战方式学习

107412 学习 · 786 问题

查看课程

相似问题