那些年我们遇到的BUG之一

问题:There is no getter for property named 'id' in 'class java.lang.String'


第一直觉:自动生成没有生产Id


不对啊,我写了的说,清空重新跑一遍,妈的,还是这个错。

网上搜答案


他们是这样的错,基本就是说加个get方法就行了

但是我的是

<insert id="insert" parameterType="induction">
		INSERT INTO tb_induction(
			id, 
			title,
			apply_address,
			apply_office,
			interview_date,
			interview_address,
			employed_name,
			positive_money,
			trial_money,
			employed_office,
			employed_job,
			job_level,
			work_date,
			phone,
			positive_date,
			contract_signed_date,
			contract_start_date,
			contract_end_date,
			create_by,
			create_date,
			update_by,
			update_date,
			del_flag
		)values(
			#{id}, 
			#{title},
			#{applyAddress.id},
			#{applyOffice.id},
			#{interviewDate},
			#{interviewAddress},
			#{employedName},
			#{positiveMoney},
			#{trialMoney},
			#{employedOffice.id},
			#{employedJob},
			#{jobLevel},
			#{workDate},
			#{phone},
			#{positiveDate},
			#{contractSignedDate},
			#{contractStartDate},
			#{contractEndDate},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			'0'
		)
	</insert>

就一个很简单的SQL语句,打印台是这样的

 - ==>  Preparing: INSERT INTO tb_induction( id, title, apply_address, apply_office, interview_date, interview_address, employed_name, positive_money, trial_money, employed_office, employed_job, job_level, work_date, phone, positive_date, contract_signed_date, contract_start_date, contract_end_date, create_by, create_date, update_by, update_date, del_flag )values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '0' ) 

扫描二维码关注公众号,回复: 2093995 查看本文章

找人解决:第一句话是不是编译问题啊,看看class文件。

直觉:绝对就是编译错误,不然不可能出错,查看class文件

反编译class文件


fuck 男人的第六感绝对靠不住。

debugger查看数据


有两条数据,一个有值,一个没有。会不会是这个错

看看其他的数据提交


这是印章刻制申请,这样是没问题的啊

对比一下所有代码

错误的



再看看正确的



虽然还没写全,但是插入一条数据是没问题的啊。

加个注解吧


我这是重写父类方法。你别再给我报错了委屈,还是错。

数据库类型换一个吧,不叫char,改成varchar委屈,还是错。

ok,你牛,我是解决不了了。我们换个名字吧

INSERT INTO tb_induction(
			induction_id, 
			title,
			apply_address,
			apply_office,
			interview_date,
			interview_address,
			employed_name,
			positive_money,
			trial_money,
			employed_office,
			employed_job,
			job_level,
			work_date,
			phone,
			positive_date,
			contract_signed_date,
			contract_start_date,
			contract_end_date,
			create_by,
			create_date,
			update_by,
			update_date,
			del_flag
		)values(
			#{inductionId}, 
			#{title},
			#{applyAddress.id},
			#{applyOffice.id},
			#{interviewDate},
			#{interviewAddress},
			#{employedName},
			#{positiveMoney},
			#{trialMoney},
			#{employedOffice.id},
			#{employedJob},
			#{jobLevel},
			#{workDate},
			#{phone},
			#{positiveDate},
			#{contractSignedDate},
			#{contractStartDate},
			#{contractEndDate},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			'0'
		)

我去


我和你杠上了,看看到底是什么错。PS:未完待续

早上来了,花了几分钟解决问题,果然睡了一觉,脑袋都清醒了。

仔细看了一下报错信息,反射异常。String类里面没有“id”的get方法。我这个类型不是string,是自定义实体类啊,再看看哪儿有id,对着实体类看一遍。原来设置的employeeOffice的类型不是Office实体类,而是String。修改一下类型,解决问题

猜你喜欢

转载自blog.csdn.net/yijianqingyu/article/details/80932902