NutzCN Logo
问答 Caused by: org.nutz.castor.FailToCastObjectException
发布于 1996天前 作者 akun 1995 次浏览 复制 上一个帖子 下一个帖子
标签:
org.nutz.dao.DaoException: org.nutz.castor.FailToCastObjectException: Fail to cast '1004.56' to <int>
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:116)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:89)
	at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:75)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:73)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:56)
	at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:200)
	at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:192)
	at cn.wizzer.framework.base.service.BaseServiceImpl.fastInsert(BaseServiceImpl.java:274)
	at cn.wizzer.app.wage.modules.services.impl.WageCalculationDetailServiceImpl.handle(WageCalculationDetailServiceImpl.java:790)
	at cn.wizzer.app.wage.modules.services.impl.WageCalculationDetailServiceImpl$$NUTZAOP._aop_invoke(WageCalculationDetailServiceImpl.java:1)
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
	at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at cn.wizzer.app.wage.modules.services.impl.WageCalculationDetailServiceImpl$$NUTZAOP.handle(WageCalculationDetailServiceImpl.java:1)
	at com.alibaba.dubbo.common.bytecode.Wrapper5.invokeMethod(Wrapper5.java)
	at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)
	at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76)
	at com.alibaba.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:52)
	at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
	at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:62)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:73)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:138)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:104)
	at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:96)
	at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:173)
	at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)
	at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.castor.FailToCastObjectException: Fail to cast '1004.56' to <int>
	at org.nutz.castor.castor.String2Number.cast(String2Number.java:45)
	at org.nutz.castor.castor.String2Number.cast(String2Number.java:19)
	at org.nutz.castor.Castors.cast(Castors.java:253)
	at org.nutz.castor.Castors.castTo(Castors.java:317)
	at org.nutz.dao.jdbc.Jdbcs$Adaptor$4.set(Jdbcs.java:343)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:318)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:23)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:159)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:105)
	... 46 more
Caused by: java.lang.NumberFormatException: For input string: "1004.56"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.valueOf(Integer.java:766)
	at org.nutz.castor.castor.String2Integer.valueOf(String2Integer.java:19)
	at org.nutz.castor.castor.String2Integer.valueOf(String2Integer.java:5)
	at org.nutz.castor.castor.String2Number.cast(String2Number.java:39)
	... 60 more

使用 dao().fastInsert()时插入数据时,其中'1004.56'在java中是String类型,数据库中对应的字段是text类型,
但是不能转换到int是什么鬼,求大佬指点一波

10 回复

实体类怎么定义的?是不是哪里写成int了

该属性的声明贴一下

这个没有实体类,是用

            summaryList.get(0).put(".table", "wage_summary");
            dao().clear("wage_summary", Cnd.where("calculationId", "=", calculationId));
            dao().fastInsert(summaryList);

其中List summaryList = this.list(orderSql);
@Wizzercn
@wendal

写个实体类试试

@wendal 这个summary的字段不是确定的,不能写实体类

传入的数据,第一条数据的这个字段是int值,但后面的某条记录是String,是不是这样?

需要类型一致的

添加回复
请先登陆
回到顶部