There is no getter for property named 'user' in 'class com.jyr.wh.domain.User' 异常

今天在使用mybatis时,出现了一个问题:There is no getter for property named ‘user‘ in ‘class com.jyr.wh.domain.User,现记录下来

使用注解的形式写sql语名,参数为一个对象

以下为正确写法:

@Insert(    "INSERT INTO t_user(openId,nickName,gender,language,city,province,country," +            "avatarUrl,unionId,appid,timestamp) " +    "VALUES(#{openId},#{nickName},#{gender},#{language},#{city},#{province},#{country}," +            "#{avatarUrl},#{unionId},#{watermark.appid},#{watermark.timestamp})")int insert(User user);
import java.io.Serializable;

public class User implements Serializable {

private String openId;    private String nickName;    private String gender;    private String language;    private String city;    private String province;    private String country;    private String avatarUrl;//头像    private String unionId;    private WaterMark watermark;

public class WaterMark{        private String appid;        private String timestamp;        }    }}

以上省略get、set方法

报错找不到user那是因为我的sql写错了,在values的参数中加了形参

@Insert(    "INSERT INTO t_user(openId,nickName,gender,language,city,province,country," +            "avatarUrl,unionId,appid,timestamp) " +    "VALUES(#{user.openId},#{user.nickName},#{user.gender},#{user.language},#{user.city},#{user.province},#{user.country}," +            "#{user.avatarUrl},#{user.unionId},#{user.watermark.appid},#{user.watermark.timestamp})")int insert(User user);

在使用注解方式时形参不用写,只写传的对象的属性即可,加上会报以上错误。

~~~~~~~~~~ 完 ~~~~~~~~~~~~

There is no getter for property named 'user' in 'class com.jyr.wh.domain.User' 异常

原文地址:https://www.cnblogs.com/skyxia/p/10202068.html

时间: 2024-10-31 03:14:56

There is no getter for property named 'user' in 'class com.jyr.wh.domain.User' 异常的相关文章

There is no getter for property named 'NULL' in ……

往往细节上的错误事最要命的事情,当你看着代码,逻辑上没有问题,但是却又曝出一些莫名其妙不知所以的错,你百度了 说出来的原因又是乱七八糟的鸡肋!很无助,纠结了很久,浪费了很多宝贵的时间--看代码! <update id="Updateuser2" parameterType="User"> update ckx_user <set> <if test="userName != NULL"> userName=#{

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;userId&#39; in &#39;class java.lang.String&#39;

[ERROR] 2017-01-18 04:37:06:231 cn.dataenergy.common.CenterHandlerExceptionResolver (CenterHandlerExceptionResolver.java:44) - 统一捕获异常: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Th

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

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;parentId&#39; in &#39;class java.lang.String&#39;

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:333) at org.apache.ibatis.reflection.Meta

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 ‘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;***&#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=

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

现在流行的 ssm(spring + struts2 + myBatis)  持久层的mybatis是需要配置映射器的,找了个demo连接的数据库是mysql 于是就修改了一下弄成了连接oracle的 一切就绪之后跑起来 执行插入操作的时候问题来了 ,报了一个这个错我的表是B 字段是id ,user_name ,password  实例类的字段是 id , userName,password, 这里有个user_name 和userName 搞了一下午弄的头疼,后来发现了猫腻, There is