NutzCN Logo
问答 nutzwk怎么获取dao查询其他表
发布于 2164天前 作者 qq_43bc7d85 2058 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method list in the service cn.wizzer.app.sb.modules.services.SbGjsjService. Tried 3 times of the providers [192.168.1.112:10343] (1/1) from the registry 192.168.1.103:2181 on the consumer 192.168.1.112 using the dubbo version 2.6.1. Last error is: Failed to invoke remote method: list, provider: dubbo://192.168.1.112:10343/cn.wizzer.app.sb.modules.services.SbGjsjService?anyhost=true&application=wk-nb-web-platform&check=false&dubbo=2.6.1&generic=false&interface=cn.wizzer.app.sb.modules.services.SbGjsjService&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=13468&register.ip=192.168.1.112&remote.timestamp=1526989925944&side=consumer&timestamp=1526996338974, cause: Failed to send message Request [id=8, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=list, parameterTypes=[interface org.nutz.dao.sql.Sql], arguments=[select * from sb_sjzb], attachments={path=cn.wizzer.app.sb.modules.services.SbGjsjService, interface=cn.wizzer.app.sb.modules.services.SbGjsjService, version=0.0.0}]] to /192.168.1.112:10343, cause: Serialized class org.nutz.dao.impl.sql.callback.FetchEntityCallback must implement java.io.Serializable
 Java field: protected org.nutz.dao.sql.SqlCallback org.nutz.dao.impl.sql.NutSql.callback
12 回复

这是调用了啥方法???

上面是调用了Service的list()
Service.getEntity(),Service.getMap(),Service.dao(),也是这样

贴你的代码

Record sjzb =sbGjsjService.list(Sqls.fetchEntity("select * from sb_sjzb ").setCondition(Cnd.where("cldjh","=",sbgjsj.get("cldjh")).and("zdjh","=",sbgjsj.get("zdjh")).and("dwdm","=",sbgjsj.get("dwdm")))).get(0);

sbGjsjService是继承nutzwk的BaseService,list也是BaseService的方法

把Sql对象传给Service执行? 这不合理的, 应该把上述参数做成方法签名来调用, 例如

public Record queryXXXX(String cldjh, String sbgjsj, String dwdm);

??

 public List<Record> list(Sql sql) {
        sql.setCallback(Sqls.callback.records());
        this.dao().execute(sql);
        return sql.getList(Record.class);

    }

为什么我调用dao()获取dao也是上诉这种情况

因为这些直接调用dao层的方法, 是以前的版本遗留的, 并不能在微服务环境下使用

哦,这是需要带Service层写方法,然后Controller里面调用是吗

Service里面可以直接用this.dao()获取吗

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