Model setOrPut 一个列表对象报错

用在一多对查询上,A表关联B表,是一对多的关系,现在查询A表一条记录,需要带上B表多条记录。image.png

前台查询时报错了

java.lang.RuntimeException: java.lang.IllegalAccessException: Class com.jfinal.json.JFinalJsonKit$BeanToJson can not access a member of class java.util.stream.AbstractPipeline with modifiers "public final"
	at com.jfinal.json.JFinalJsonKit$BeanToJson.toJson(JFinalJsonKit.java:556)
	at com.jfinal.json.JFinalJsonKit.modelAndRecordToJson(JFinalJsonKit.java:369)
	at com.jfinal.json.JFinalJsonKit$ModelToJson.toJson(JFinalJsonKit.java:326)
	at com.jfinal.json.JFinalJsonKit$ModelToJson.toJson(JFinalJsonKit.java:319)
	at com.jfinal.json.JFinalJsonKit.iteratorToJson(JFinalJsonKit.java:490)
	at com.jfinal.json.JFinalJsonKit$CollectionToJson.toJson(JFinalJsonKit.java:425)
	at com.jfinal.json.JFinalJsonKit$CollectionToJson.toJson(JFinalJsonKit.java:419)
	at com.jfinal.json.JFinalJsonKit$BeanToJson.toJson(JFinalJsonKit.java:549)
	at com.jfinal.json.JFinalJson.toJson(JFinalJson.java:68)
	at com.jfinal.json.MixedJson.toJson(MixedJson.java:37)
	at com.jfinal.kit.JsonKit.toJson(JsonKit.java:28)
	at com.jfinal.render.JsonRender.<init>(JsonRender.java:125)
	at com.jfinal.render.RenderFactory.getJsonRender(RenderFactory.java:103)
	at com.jfinal.core.Controller.renderJson(Controller.java:1146)
	at com.zshsoft.controller.base.BaseController.renderObj(BaseController.java:95)
	at com.zshsoft.controller.market.BusinessOpportunityTallController.findByBusOppId(BusinessOpportunityTallController.java:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:97)
	at com.zshsoft.web.intercept.ThreadLocalIntercept.intercept(ThreadLocalIntercept.java:27)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:91)
	at com.zshsoft.web.intercept.LoginInterceptor.intercept(LoginInterceptor.java:42)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:91)
	at com.jfinal.ext.interceptor.SessionInViewInterceptor.intercept(SessionInViewInterceptor.java:44)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:91)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:88)
	at com.jfinal.ext.handler.UrlSkipHandler.handle(UrlSkipHandler.java:46)
	at com.zshsoft.web.handler.BasePathHandler.handle(BasePathHandler.java:37)
	at com.zshsoft.web.handler.SessionHandler.handle(SessionHandler.java:18)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:90)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
	at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117)
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:841)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalAccessException: Class com.jfinal.json.JFinalJsonKit$BeanToJson can not access a member of class java.util.stream.AbstractPipeline with modifiers "public final"
	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296)
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288)
	at java.lang.reflect.Method.invoke(Method.java:491)
	at com.jfinal.json.JFinalJsonKit$BeanToJson.toJson(JFinalJsonKit.java:531)
	... 64 more

请问如何解决?

评论区

杜福忠

2021-06-14 23:12

stream写法提出来,单写一行,把执行结果放入setOrPut就可以,不要使用对象

北流家园网

2021-06-15 07:44

@杜福忠 可以了,谢谢!

热门反馈

扫码入社