错误提示: IllegalArgumentException occurred calling getter of *

主要错误信息:

- IllegalArgumentException in class: com.gdcy.bean.Department, getter method of property: id

org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred calling getter of com.gdcy.bean.Department.id; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.gdcy.bean.Department.id

 

 

 

Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.gdcy.bean.Department.id

 

Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class

 

产生错误原因:映射文件中Department.id的类型不匹配

造成经过:在制作项目中,因为贪方便,Department外键对象使用了String类型,打算只读取它的ID来使用就算了,但又糊涂的在配置文件中设置了<many-to-one>的关系,结果在匹配类型的时候成了Department对象和String对象,因此匹配出错,提示类型不匹配

解决方法:1修改hbm.xml文件的多对一,2bean文件中改回读取Department对象

Orther:以上犯的错误比较特殊,常见的:A表中id为int类型,却在A的bean中将id设置为了String,也会导致上述错误(即java类字段的类型与表字段的类型/长度不一致)

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值