NutzCN Logo
问答 关于list集合插入数据库问题
发布于 2237天前 作者 木易 1568 次浏览 复制 上一个帖子 下一个帖子
标签:

今天试了下向数据库存入list,出现问题,请教一下

NutMap map = Json.fromJson(NutMap.class, json);
        List<Cai_value> caiValues = new ArrayList<>();
        String productId = "7fec75ec480d44fb99d23d5a22fbf3a6";
        map.forEach((k, v)->{
            try {
                caiValues.add(new Cai_value(){{
                    setProduct_id(productId);
                    setValue(v.toString());
                    setAttr_id(Integer.parseInt(k));
                }});
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        });
        caiValueService.insert(caiValues);
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method fastInsert in the service cn.wizzer.app.cai.modules.services.CaiValueService. Tried 3 times of the providers [192.168.10.34:20882] (1/1) from the registry 127.0.0.1:2181 on the consumer 192.168.10.34 using the dubbo version 2.6.2. Last error is: Failed to invoke remote method: fastInsert, provider: dubbo://192.168.10.34:20882/cn.wizzer.app.cai.modules.services.CaiValueService?anyhost=true&application=wk-nb-web-platform&check=false&dubbo=2.6.2&generic=false&interface=cn.wizzer.app.cai.modules.services.CaiValueService&methods=updateWithVersion,data,insertRelation,insertWith,insertOrUpdate,dao,getMaxId,getSubPath,query,count,getField,vDelete,list,execute,fetchx,getMap,updateAndIncrIfMatch,updateLinks,fetchLinks,updateRelation,fastInsert,update,insert,insertLinks,getParentPath,delete,updateIgnoreNull,clear,getEntity,updateWith,fetch,exists,listPage&pid=39768&register.ip=192.168.10.34&remote.timestamp=1541587410151&side=consumer&timestamp=1541596829119, cause: Failed to send message Request [id=5, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=fastInsert, parameterTypes=[class java.lang.Object], arguments=[[/*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@9a79d42*/{"value":"32","attr_id":671,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@67f671db*/{"value":"132","attr_id":672,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@3052d09e*/{"value":"32","attr_id":673,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@34347f87*/{"value":"132","attr_id":674,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@184b33d*/{"value":"132","attr_id":675,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@55a8627f*/{"value":"1","attr_id":676,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@73d89e74*/{"value":"21","attr_id":677,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@64870fcf*/{"value":"321","attr_id":678,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@40be4539*/{"value":"321","attr_id":679,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@56136ccb*/{"value":"321","attr_id":680,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}]], attachments={path=cn.wizzer.app.cai.modules.services.CaiValueService, interface=cn.wizzer.app.cai.modules.services.CaiValueService, version=0.0.0}]] to /192.168.10.34:20882, cause: Serialized class cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$$NUTZAOP must implement java.io.Serializable
 Java field: final cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2.this$0
	at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:102)
	at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:238)
	at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:75)
	at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
	at com.alibaba.dubbo.common.bytecode.proxy10.fastInsert(proxy10.java)
	at cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController.test(OpenProductController.java:241)
	at cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$FM$test$cff301be46c87e2fbea60f4ef344bacb.invoke(OpenProductController.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:38)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:35)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.NutShiroProcessor.process(NutShiroProcessor.java:52)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:48)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:21)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at cn.wizzer.app.web.commons.filter.RouteFilter.doFilter(RouteFilter.java:31)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.nutz.mvc.WhaleFilter.doFilter(WhaleFilter.java:171)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
	at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:215)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:531)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to send message Request [id=5, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=fastInsert, parameterTypes=[class java.lang.Object], arguments=[[/*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@9a79d42*/{"value":"32","attr_id":671,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@67f671db*/{"value":"132","attr_id":672,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@3052d09e*/{"value":"32","attr_id":673,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@34347f87*/{"value":"132","attr_id":674,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@184b33d*/{"value":"132","attr_id":675,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@55a8627f*/{"value":"1","attr_id":676,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@73d89e74*/{"value":"21","attr_id":677,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@64870fcf*/{"value":"321","attr_id":678,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@40be4539*/{"value":"321","attr_id":679,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}, /*cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2@56136ccb*/{"value":"321","attr_id":680,"product_id":"7fec75ec480d44fb99d23d5a22fbf3a6"}]], attachments={path=cn.wizzer.app.cai.modules.services.CaiValueService, interface=cn.wizzer.app.cai.modules.services.CaiValueService, version=0.0.0}]] to /192.168.10.34:20882, cause: Serialized class cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$$NUTZAOP must implement java.io.Serializable
 Java field: final cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2.this$0
	at com.alibaba.dubbo.remoting.transport.netty.NettyChannel.send(NettyChannel.java:110)
	at com.alibaba.dubbo.remoting.transport.AbstractClient.send(AbstractClient.java:265)
	at com.alibaba.dubbo.remoting.transport.AbstractPeer.send(AbstractPeer.java:53)
	at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeChannel.request(HeaderExchangeChannel.java:115)
	at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeClient.request(HeaderExchangeClient.java:90)
	at com.alibaba.dubbo.rpc.protocol.dubbo.ReferenceCountExchangeClient.request(ReferenceCountExchangeClient.java:83)
	at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:95)
	at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:148)
	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.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:54)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:77)
	at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
	at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:78)
	... 73 more
Caused by: java.lang.RuntimeException: Serialized class cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$$NUTZAOP must implement java.io.Serializable
 Java field: final cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$2.this$0
	at com.alibaba.com.caucho.hessian.io.JavaSerializer$FieldSerializer.serialize(JavaSerializer.java:300)
	at com.alibaba.com.caucho.hessian.io.JavaSerializer.writeInstance(JavaSerializer.java:280)
	at com.alibaba.com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:247)
	at com.alibaba.com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:391)
	at com.alibaba.com.caucho.hessian.io.CollectionSerializer.writeObject(CollectionSerializer.java:99)
	at com.alibaba.com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:391)
	at com.alibaba.dubbo.common.serialize.hessian2.Hessian2ObjectOutput.writeObject(Hessian2ObjectOutput.java:88)
	at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.encodeRequestData(DubboCodec.java:176)
	at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encodeRequest(ExchangeCodec.java:234)
	at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:71)
	at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:38)
	at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:80)
	at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:66)
	at com.alibaba.dubbo.remoting.transport.netty.NettyHandler.writeRequested(NettyHandler.java:98)
	at org.jboss.netty.channel.Channels.write(Channels.java:611)
	at org.jboss.netty.channel.Channels.write(Channels.java:578)
	at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:251)
	at com.alibaba.dubbo.remoting.transport.netty.NettyChannel.send(NettyChannel.java:100)
	... 89 more
Caused by: java.lang.IllegalStateException: Serialized class cn.wizzer.app.web.modules.controllers.platform.open.OpenProductController$$NUTZAOP must implement java.io.Serializable
	at com.alibaba.com.caucho.hessian.io.SerializerFactory.getDefaultSerializer(SerializerFactory.java:395)
	at com.alibaba.com.caucho.hessian.io.SerializerFactory.getSerializer(SerializerFactory.java:369)
	at com.alibaba.com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:389)
	at com.alibaba.com.caucho.hessian.io.JavaSerializer$FieldSerializer.serialize(JavaSerializer.java:298)
	... 106 more
1 回复
new Cai_value(){{
                    setProduct_id(productId);
                    setValue(v.toString());
                    setAttr_id(Integer.parseInt(k));
                }}

这是建立一个内部类, 会依赖OpenProductController, 不死才怪

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