ibatis javaBean 书写问题

本文探讨了在使用iBatis框架时遇到的一个常见问题:即JavaBean的字段名称与SQL映射文件中的字段名称不匹配导致的异常。特别关注了大小写敏感的问题,并给出了相应的解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

There is no WRITEABLE property named 'id' in class 'com.study.bean.Student'

很奇怪,id是完全对应一致的,可是出现这个错误,在网上查了,说javabean里面的变量和SQLMAP里面的不一样,如javabean里面 Userid在SQLMAP里面 要写userid,只默认识别小写,不能写成大写。

经测试,在ibatis中对象属性的头两个字母不能大写,在javabean里写lUUID形式的,使用resultMap时不认该字段

写成llUUID就没事了

 

 

 

Exception in thread "main" org.mybatis.spring.MyBatisSystemException: ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'birth' in 'class com.li.demo011.bean.Vip' ### The error may exist in file [D:\work\code\demo-011\target\classes\mapper\VipMapper.xml] ### The error may involve com.li.demo011.repository.VipMapper.insert-Inline ### The error occurred while setting parameters ### SQL: insert into t-vip(id,name,card_number,birth) values(null,?,?,?) ### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'birth' in 'class com.li.demo011.bean.Vip' at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:99) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:347) at jdk.proxy2/jdk.proxy2.$Proxy47.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:224) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62) at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:141) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) at jdk.proxy2/jdk.proxy2.$Proxy48.insert(Unknown Source) at com.li.demo011.service.VipServiceImpl.save(VipServiceImpl.java:17) at com.li.demo011.Demo011Application.main(Demo011Application.java:18) Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'birth' in 'class com.li.demo011.bean.Vip' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:385) at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:160) at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:156) at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:50) at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:115) at org
最新发布
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值