iBatis java.lang.RuntimeException: Error setting property

数据库转换异常:ApkProductDto对象中null无法转换为INT类型
博客讨论了一个在ApkProductDto对象中使用ifnull函数解决数据库列为空值时无法转换为INT类型的问题,避免了因null转换导致的UncategorizedSQLException。
[b]系统运行时报如下错误:[/b]
[java.sql.PreparedStatement]org.springframework.jdbc.UncategorizedSQLException: 

SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error

code [0];
--- The error occurred in com/windowclick/abb/ibatis/apkProduct.xml.
--- The error occurred while applying a result map.
--- Check the getApkProductDtoBySearch-AutoResultMap.
--- The error happened while setting a property on the result object.
--- Cause: java.lang.RuntimeException: Error setting property 'setShow_push_ad' of

'com.windowclick.abb.dto.ApkProductDto@38daa6a6'. Cause:

java.lang.IllegalArgumentException; nested exception is

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/windowclick/abb/ibatis/apkProduct.xml.


一看问题,以为是ApkProductDto对象中没有show_push_ad属性,被同事修改了,但实际正常,通过检查,发现[color=red]数据库中此列数据为空,但实际数据库设置此字段属性为INT类型,默认值为0,当查询转换时,不能把null转换成int类型,如此异常产生[/color],如果实际应用中确实有空的数据,但需转换成其他类型,可以用ifnull(字段名,默认值)进行判断设置默认值
### Error querying database. Cause: java.lang.RuntimeExceeption: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='itemlId', mode=IN, javatype=class java.lang.Lo ### The error may exist in URL [jar:nested:/srm-mdm.jar/!E300T-INF/classes/!/mapper/cux/HcItemReqHeaderMapper.xml] ### The error_may_involve defaultParameterMap ### The error occurred while setting parameters ### SQL: /*org.srm.mdm.cux.infra.mapper.HcItemReqHeaderMapper.ageItemReqHeader_COUNT*/ SELECT count(0) FROM smdm_item_req ir LEFT JOIN smdm_item_req_header irh ON ir.item_req_header_id = irh.iitem_req_header_id LEFT JOIN srm.iam_user iu1 ON iu1.id = irh.created_by LEFT JOIN srm.iam_user iu2 ON iu2id ## Cause: java.lang.RuntimeException: org.apache.ibatis.ttype.TypeException: Could not set parameters for mapping:ParameterMapping{property='itemId', mode=IN, javaType=class java.lang.Long, jdbcType=BIGINT, numericScale=null, resultMapid='nullL', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error seetting non null for parameter #5 with JdbcType BIGINT. Try setting a different JdbcType for this parameteer or a different configuration property. Cause: java.lang.ClassCastException: class java.lang.Stringcannot be cast to class java.lang.Long (java.lang.String and java.lang.Long are in module java.base of loader 'bootstrap.) at org.apache.ibatis.exceptions.ExceptionFactory.wrapExcepotion(ExceptionFactory.java:30) ~[mybatis-3.5.14.jar!/:3.514] at org.apache.ibatis.session.defaults.DefaultSqlSession.seelectlist(DefaultSqlSession.java:156) ~[mybatis-3.5.14.jar!/:3.5.14] at org.apache.ibatis.session.defaults.DefaultSqlSession.seledtlist(DefaultSqlSession.java:147) ~[mybatis-3.5.14.jar!/:3.514] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectist(DefaultSqlSession.java:142) ~[mybatis-3.5.14.jar!/:3.5.14] at jdk.internal.reflect.GeneratedMethodAccessor348.irnvoke(Unknown Source) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessonImpl.invoke(DelegatingMethodAccessorimpl.java:43) ~[na:na1 at java.base/java.lang.reflect.Method.invoke(Method.java:569)~[na:na] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425) ~[mybaatis-spring-3.0.3.jar!/:3.0.3] ... 276 common frames omitted
最新发布
11-21
2025-07-04 11:17:14.617 ERROR 53516 --- [main] o.s.boot.SpringApplication : 818 Application run failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderMapper' defined in file [D:\myworkspace\hr_direct-master\hr-direct-domain\hr-direct-order\hr-direct-order-repository\target\classes\com\alibaba\hrdirect\order\repository\api\OrderMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hrDirectSqlSessionFactory' defined in class path resource [com/alibaba/hrdirect/infrastructure/tddl/ShardingConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\myworkspace\hr_direct-master\hr-direct-domain\hr-direct-order\hr-direct-order-repository\target\classes\mapper\OrderMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [D:\myworkspace\hr_direct-master\hr-direct-domain\hr-direct-order\hr-direct-order-repository\target\classes\mapper\OrderMapper.xml]'. Cause: java.lang.RuntimeException: Failed to set field value
07-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值