问答详情
源自:3-6 dao层开发

updateArea测试不通过

为什么我的AreaDaoTest类的updateArea测试不通过,org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'NULL' in 'class com.imooc.demo1.entity.Area'

提问者:宝慕林0045603 2019-02-24 23:18

个回答

  • qq_可乐_68
    2019-02-25 17:14:06
    已采纳

    大概意思是说你有一个参数为空,建议您先把代码贴出来

  • qq_可乐_68
    2019-02-26 08:58:30

    我看你代码没有错呀,数据库设计怎么样呢?ResultMap配置(数据库跟实体类的映射配置)还有你试过DeBug找没?

  • 宝慕林0045603
    2019-02-25 21:16:11

    public void updateArea(){   
         Area area = new Area();     
           area.setAreaName("西苑");    
               area.setAreaId(3);     
                  area.setLastEditTime(new Date());   
                       int effectedNum = areaDao.updateArea(area);  
                             assertEquals(1,effectedNum);  
                              }

    <update id="updateArea" parameterType="com.imooc.demo1.entity.Area">

            UPDATE tb_area

            <set>

                <if test="areaName != NULL">area_name=#{areaName},</if>

                <if test="priority != NULL">priority=#{priority},</if>

                <if test="lastEditTime != NULL">last_edit_time=#{lastEditTime}</if>

            </set>

            WHERE area_id=#{areaId}

        </update>

    public class Area {

        // 主键ID

        private Integer areaId;

        // 名称

        private String areaName;

        // 权重

        private Integer priority;

        // 创建时间

        private Date createTime;

        //更新时间

        private Date lastEditTime;


        public Integer getAreaId() {

            return areaId;

        }


        public void setAreaId(Integer areaId) {

            this.areaId = areaId;

        }


        public String getAreaName() {

            return areaName;

        }


        public void setAreaName(String areaName) {

            this.areaName = areaName;

        }


        public Integer getPriority() {

            return priority;

        }


        public void setPriority(Integer priority) {

            this.priority = priority;

        }


        public Date getCreateTime() {

            return createTime;

        }


        public void setCreateTime(Date createTime) {

            this.createTime = createTime;

        }


        public Date getLastEditTime() {

            return lastEditTime;

        }


        public void setLastEditTime(Date lastEditTime) {

            this.lastEditTime = lastEditTime;

        }