NutzCN Logo
问答 使用create方法创建sql,拿不到数据
发布于 2809天前 作者 qq_de47eb0c 2004 次浏览 复制 上一个帖子 下一个帖子
标签:

Sql sql = Sqls.create(" select\n" +
" ps.id as id,\n" +
" ps.user_id as userId,\n" +
" ps.provider_id as providerId,\n" +
" pbi.agent_id as agentId,\n" +
" ps.goods_category_id as goodsCategoryId,\n" +
" gc.goods_category_name as goodsCategoryName,\n" +
" GROUP_CONCAT(bs.service_type_name) as serviceTypeName,\n" +
" ps.apply_time as applyTime\n" +
" from provider_service_goods_category ps\n" +
" JOIN goods_category gc ON gc.id= ps.goods_category_id\n" +
" join provider_base_info pbi on pbi.id=ps.provider_id\n" +
" LEFT JOIN base_service_type bs ON bs.id= ps.service_type_id\n" +
" where pbi.agent_id=@agentId and ps.provider_id=@providerId" +
" GROUP BY ps.goods_category_id");
sql.setParam("agentId", agentId).setParam("providerId", providerId);
Sql execute = this.dao.execute(sql);
List list=execute.getList(GoodsAndServiceTypeAgent.class);//这里为Null 参数 粘贴到数据库执行 数据都没文艺 执行getList 拿不到为何
return list;

4 回复

实体类参数 与sql字段一致

要设置回调

// 设置回调
Sql sql = Sqls.create(....);
sql.setCallback(Sqls.callback.entities());
sql.setEntity(dao.getEntity(GoodsAndServiceTypeAgent.class));

// 等价于
Sql sql = Sqls.queryEntity(........);
sql.setEntity(dao.getEntity(GoodsAndServiceTypeAgent.class));

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