首页 新闻 搜索 专区 学院

我写的Mybatis怎么总是报 Invalid bound statement (not found):

0
悬赏园豆:10 [已解决问题] 解决于 2018-08-02 13:42

映射的实体:

package com.txgl.entity;

import java.beans.SimpleBeanInfo;
import java.io.Serializable;

public class RoomEquipmentEntity  extends SimpleBeanInfo implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
  
    private Long roomEquipmentId;
    private Long engineRoomId;
    private Long equipmentId;
    private int equipmentLeft;
    private int equipmentTop;
    private int equipmentNum;
    private String equipmentName;
    
    public RoomEquipmentEntity() {
        super();
    }

    public RoomEquipmentEntity(Long roomEquipmentId, Long engineRoomId, Long equipmentId, int equipmentLeft,
            int equipmentTop, int equipmentNum, String equipmentName) {
        super();
        this.roomEquipmentId = roomEquipmentId;
        this.engineRoomId = engineRoomId;
        this.equipmentId = equipmentId;
        this.equipmentLeft = equipmentLeft;
        this.equipmentTop = equipmentTop;
        this.equipmentNum = equipmentNum;
        this.equipmentName = equipmentName;
    }

    public String getEquipmentName() {
        return equipmentName;
    }
    
    public void setEquipmentName(String equipmentName) {
        this.equipmentName = equipmentName;
    }

    public Long getRoomEquipmentId() {
        return roomEquipmentId;
    }

    public void setRoomEquipmentId(Long roomEquipmentId) {
        this.roomEquipmentId = roomEquipmentId;
    }

    public Long getEngineRoomId() {
        return engineRoomId;
    }

    public void setEngineRoomId(Long engineRoomId) {
        this.engineRoomId = engineRoomId;
    }

    public Long getEquipmentId() {
        return equipmentId;
    }

    public void setEquipmentId(Long equipmentId) {
        this.equipmentId = equipmentId;
    }

    public int getEquipmentLeft() {
        return equipmentLeft;
    }

    public void setEquipmentLeft(int equipmentLeft) {
        this.equipmentLeft = equipmentLeft;
    }

    public int getEquipmentTop() {
        return equipmentTop;
    }

    public void setEquipmentTop(int equipmentTop) {
        this.equipmentTop = equipmentTop;
    }

    public int getEquipmentNum() {
        return equipmentNum;
    }

    public void setEquipmentNum(int equipmentNum) {
        this.equipmentNum = equipmentNum;
    }

    }
}

Mapper类:

package com.txgl.mapper.db1;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

import com.txgl.entity.RoomEquipmentEntity;import com.txgl.provider.EngineRoomProvider;



public interface EngineRoomMapper {

    /**
     * 删除
     * @param equipmentIds
     */
    public void removeRoomEquipments(List<String> equipmentIds);
}

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.txgl.mapper.db1.EngineRoomMapper">
    <resultMap id="BaseResultMap" type="com.txgl.entity.RoomEquipmentEntity">
        <id column="roomEquipmentId" property="roomEquipmentId" jdbcType="BIGINT" />
        <result column="engineRoomId" property="engineRoomId" jdbcType="BIGINT" />
        <result column="equipmentId" property="equipmentId" jdbcType="BIGINT" />
    </resultMap>

    <delete id="removeRoomEquipments" parameterType="java.util.List">
        DELETE FROM ENGINEROOM_EQUIPMENT eq WHERE eq.equipmentId in 
        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>


</mapper>

大家看,我的namespace和parameterType以及在Mapper类中的方法"removeRoomEquipments"都有指定,为什么还绑定不了方法呢??

"

surriento的主页 surriento | 初学一级 | 园豆:105
提问于:2018-02-05 16:20
< >
分享
最佳答案
0

建议吧resultMap这个标签注释再试一下,如果不行仔细按下面步鄹排错
1.检查MyBatis的xml文件是否被加载,xml文件路径是否正确
2.检查xml文件中的内容是否有误
3.点击Project->右键选中clean->选中项目点击确定(有可能是编译器没有加载过来)

收获园豆:10
这片海 | 初学一级 |园豆:178 | 2018-02-05 17:38
其他回答(3)
0

delete 中用resultMap="BaseResultMap"指定map

pkyou | 园豆:98 (初学一级) | 2018-02-05 16:50
0

你传的参数名和接收的参数名不一样

小飞^_^ | 园豆:206 (菜鸟二级) | 2018-02-05 17:00
0

可以用mybatis generator自动生成相对应的dao,mapper,实体类; 而且参数为两个时,建议@Param注解来设定参数;

魂心 | 园豆:147 (初学一级) | 2018-02-05 17:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册