Ray-Yan 2016-09-19 15:07 采纳率: 100%
浏览 1166

mybatis无法删除数据,log4j显示如下异常

当使用mybatis删除数据时,log4j出现如下图异常:
图片说明
请问可能的原因是什么?
相关代码:

 <?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="Message"> 
  <resultMap type="model.Message" id="MessageResult">
    <id column="ID" jdbcType="VARCHAR" property="id"/> 
    <result column="COMMAND" jdbcType="VARCHAR" property="command"/>
    <result column="DESCRIPTION" jdbcType="VARCHAR" property="description"/>
    <result column="CONTENT" jdbcType="VARCHAR" property="content"/>
  </resultMap>

  <select id="Message.queryAll" resultMap="MessageResult">
    SELECT ID,COMMAND,DESCRIPTION,CONTENT FROM message WHERE 1=1
    <if test="command != null and !&quot;&quot;.equals(command.trim())">and COMMAND LIKE '%' #{command} '%'</if>
    <if test="description != null and !&quot;&quot;.equals(description.trim())">and DESCRIPTION LIKE '%' #{description} '%'</if>
  </select>

  <delete id="deleteOne" parameterType="int">
    DELETE FROM message WHERE ID=#{_parameter}
  </delete>
</mapper>

public void deleteOne(int id){
        DBAccess dbAccess = new DBAccess();
        SqlSession sqlSession = null;
        try{
            sqlSession = dbAccess.getSqlSession();//实例化并打开数据库会话
            sqlSession.delete("Message.deleteOne",id);//message.xml配置文件中对应ID号的SQL语句
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            if(sqlSession!=null){
                sqlSession.close();
            }
        }
    }

    public class MaintainService {
    public void deleteOne(String id){
        if(id != null && !"".equals(id.trim())){
            MessageDAO messageDao = new MessageDAO();
            messageDao.deleteOne(Integer.valueOf(id));
        }

    }

}
  • 写回答

1条回答 默认 最新

  • a719195733 2016-09-20 00:46
    关注

    xml中把类型 int换java.lang. Integer试试

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog