NutzCN Logo
问答 我想问一下为什么不能转为list
发布于 3234天前 作者 qq_722cb381 1784 次浏览 复制 上一个帖子 下一个帖子
标签:
代码:
Sql sqlcount =dao.sqls().create("find.mobileauth.by.serch.size");
    sqlcount.setCallback(Sqls.callback.entity());
    Entity<MagicCardCode> entity =dao.getEntity(MagicCardCode.class);
    sqlcount.params().set("searchKey", searchKey);
    sqlcount.params().set("keyid", keyid);
    sqlcount.setEntity(entity);
    dao.execute(sqlcount);
    List<MagicCardCode> size=sqlcount.getList(MagicCardCode.class);

    sql语句:
    /*find.mobileauth.by.serch.size*/

SELECT * from
(SELECT
ROW_NUMBER() OVER (ORDER BY mau.id) AS NO,
mau.id AS id,
map.name AS mobilename,
mau.no AS nos,
mau.password AS password,
mau.devices AS devices,
mau.firstlogin AS firstlogin,
mau.uselog AS uselog,
mau.description AS descs,
mau.appid AS appid

FROM
mc_magiccard_code mau
LEFT JOIN mc_magiccard map ON map.id = mau.appid
$condition WHERE mau.no like @searchKey OR mau.password like @searchKey OR map.name like @searchKey
)t
$condition WHERE t.appid=@keyid

报错:
01-15 18:23:21.108 WARN - [FailProcessor.http-bio-8070-exec-8] Error@/magiccardcode/search :
java.lang.ClassCastException: com.nutz.magiccard.bean.magiccardcode.MagicCardCode cannot be cast to java.util.List
at org.nutz.dao.impl.sql.NutStatement.getList(NutStatement.java:113)
at com.nutz.magiccard.service.magiccardcode.impl.MagicCardCodeService.searchByKey(MagicCardCodeService.java:119)
at com.nutz.magiccard.service.magiccardcode.impl.MagicCardCodeService$$NUTZAOP._aop_invoke(MagicCardCodeService.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.LoggingMethodInterceptor.filter(LoggingMethodInterceptor.java:48)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at com.nutz.magiccard.service.magiccardcode.impl.MagicCardCodeService$$NUTZAOP.searchByKey(MagicCardCodeService.java)
at com.nutz.magiccard.module.magiccardcode.MagicCardCodeModule.search(MagicCardCodeModule.java:186)
at com.nutz.magiccard.module.magiccardcode.MagicCardCodeModule$$NUTZAOP._aop_invoke(MagicCardCodeModule.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 com.dgj.nutz.interceptor.ExecutionTimeInterceptor.filter(ExecutionTimeInterceptor.java:28)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at com.dgj.nutz.interceptor.NameSpaceAndSessionInterceptor.filter(NameSpaceAndSessionInterceptor.java:33)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at org.nutz.aop.interceptor.LoggingMethodInterceptor.filter(LoggingMethodInterceptor.java:48)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at com.nutz.magiccard.module.magiccardcode.MagicCardCodeModule$$NUTZAOP.search(MagicCardCodeModule.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
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.NutActionChain.doChain(NutActionChain.java:40)
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:183)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

2 回复

你选的是 entity() 所以是单个

sqlcount.setCallback(Sqls.callback.entity());

改成entities就是List咯

sqlcount.setCallback(Sqls.callback.entities());

对 忘了 我之前犯过一次,怪我了 谢谢@wendal

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