关于myBatis的问题There is no getter for property named 'USER_NAME' in 'class com.bky.model.实例类'

现在流行的 ssm(spring + struts2 + myBatis)  持久层的mybatis是需要配置映射器的,找了个demo连接的数据库是mysql 于是就修改了一下弄成了连接oracle的

一切就绪之后跑起来 执行插入操作的时候问题来了 ,报了一个这个错我的表是B 字段是id ,user_name ,password  实例类的字段是 id , userName,password,

这里有个user_name 和userName 搞了一下午弄的头疼,后来发现了猫腻,

There is no getter for property named ‘USER_NAME‘ in ‘class com.bky.model.B‘

代码:

实体类 B

package com.bky.model;

public class B {
    private Long id;

    private String userName;

    private String password;

    public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id == null ? null : id;
	}
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password == null ? null : password.trim();
	}
}

映射器.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.bky.dao.BMapper" >

  <resultMap id="BaseResultMap" type="com.bky.model.B" >
    <id column="ID" property="id" jdbcType="INTEGER" />
    <result column="USER_NAME" property="userName" jdbcType="VARCHAR" />
    <result column="PASSWORD" property="password" jdbcType="VARCHAR" />
  </resultMap>

  <sql id="Base_Column_List" >
    ID, USER_NAME, PASSWORD
  </sql>
  

<span style="white-space:pre">	</span><!--我们重点关注一下这里 
<span style="white-space:pre">	</span>user_name 是个表字段和后面的<span style="font-family: Arial, Helvetica, sans-serif;">#{USER_NAME,jdbcType=VARCHAR} 这里错了应该写成 </span><span style="font-family: Arial, Helvetica, sans-serif;">#{userName,jdbcType=VARCHAR} 应该是属性值 啊找的好苦啊 一下午就这样浪费了 不过还是解决了 ,一开始百度了很多 有的人是属性名写错了,有的是没有set/get  总结到此分享一下 有此情况错误的 一般就这几种了希望可以帮助到初学者</span>
<span style="white-space:pre">	</span>-->

  <insert id="insertSelective" parameterType="com.bky.model.B" >
    insert into B ( USER_NAME,PASSWORD) values(#{USER_NAME,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR})
  </insert>

  <update id="updateByPrimaryKey" parameterType="com.bky.model.B" >
    update B
    set USER_NAME = #{USER_NAME,jdbcType=VARCHAR},
      PASSWORD = #{PASSWORD,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="getAll" resultMap="BaseResultMap">
  	SELECT * FROM B
  </select>
</mapper>

关于myBatis的问题There is no getter for property named 'USER_NAME' in 'class com.bky.model.实例类'

时间: 2024-08-10 17:20:22

关于myBatis的问题There is no getter for property named 'USER_NAME' in 'class com.bky.model.实例类'的相关文章

Mybatis问题:There is no getter for property named &#39;unitId&#39; in &#39;class java.lang.String&#39;

Mybatis遇到的问题 问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'unitId' in 'class java.lang.String' at org.mybatis.spring.MyBatisExceptionTransla

Mybatis 报错 There is no getter for property named &#39;***&#39; in &#39;class java.lang.String&#39;

在mapper.xml中 , 如果单参数是String类型 , 且在sql语句中对参数进行了判断 , 如下 when 中的判断 , 如果出现 if 判断也是一样的.都需要把判断中的参数用 _parameter 来代替 ,. 另外orcal中判断字段是否为空需要使用 is null , 同理,判断不为空使用 is not null . 错误查询: <select id = "select" resultMap="ResultMap" parameterType=

There is no getter for property named &#39;userSpAndSp&#39; in &#39;class com.uauth.beans.UserSpAndSp&#39;

mybatis 报错There is no getter for property named 'userSpAndSp' in 'class com.uauth.beans.UserSpAndSp' 这里userSpAndSp是我传入的参数,在where判断时 = #{userSpAndSp.enduserid,jdbcType=BIGINT} ,只要在DAO里在参数前面加上 @Param(value = "userSpAndSp")(基本数据类型无需加上@param) There

MyBatis查询传一个参数时报错:There is no getter for property named &#39;sleevetype&#39; in &#39;class java.lang.Integer

用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class java.lang.Integer 原因在于测试条件写法有误, <if test="sleevetype==0"><!-- 专属 --> exclusive=1 </if> <if test="sleevetype!=0">&l

There is no getter for property named &#39;useName&#39; in &#39;class cn.itcast.mybatis.pojo.User&#39;

org.apache.ibatis.exceptions.PersistenceException: ### Error updating database.  Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'useName' in 'class cn.itcast.mybatis.pojo.User'### The error may involve

Mybatis There is no getter for property named ‘X‘

在尝试使用mybatis的动态sql中遇到这么一个问题, 使用Mybatis查询时,其参数可以是基本数据类型或者像Integer和String这样的简单的数据对象,也可以是复杂对象(一般是指JavaBean)或者map等,当使用基本数据类型的参数时,若这个参数的使用放在了判断条件中, <!-- mybatis 动态sql--> <select id="findFruit" resultType="Fruit">     SELECT * FR

Mybatis中传参包There is no getter for property named &#39;XXX&#39; in &#39;class java.lang.String&#39;

一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType="string"> select num,name,phone from student <where> <if test = " num!=null and num!='' "> AND num = #{num} </if> <

mybatis There is no getter for property named &#39;xxxx

mybatis There is no getter for property named 'xxxx 360反馈意见截图16230322799670.png http://blog.sina.com.cn/s/blog_8ced01900101blqd.html mybatis There is no getter for property named 'xxxx

mybatis 异常 There is no getter for property named &#39;bizId&#39; in &#39;class java.lang.Long&#39;

mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long' 当使用mybatis进行传参的时候,参数只有一个时会出现这种类似的错误. 解决: 1.接口定义出,指定参数名 2.在xml 中指定类型 mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long'