NutzCN Logo
问答 oracle转mysql,nutz查询问题
发布于 2384天前 作者 jjflyx 1483 次浏览 复制 上一个帖子 下一个帖子
标签:

在oracle数据库迁移到mysql数据库,遇到子查询起别名的问题,在mysql中,子查询是必须要给表起别名的,怎么破

8 回复

那就加别名... 还能怎么破

@At
@Ok("raw")
public JSONObject orderList(HttpServletRequest req,@Param("xy_type") String xy_type,@Param("xyzt_type") String xyzt_type,@Param("xystatus") String xystatus,@Param("name") String name,@Param("page") int curPage, @Param("rows") int pageSize){
Sql sql = null;
String sqlstr = "select * from l_jsgg where 1=1 ";
sqlstr += " order by add_time desc ";
sql = Sqls.create(sqlstr);
QueryResult qr = daoCtl.listPageSql(dao, sql, curPage, pageSize);
List<Map<String,String>> list = (List<Map<String, String>>) qr.getList();
Criteria cri = Cnd.cri();
return daoCtl.listPageJson(dao, OrderBean.class, curPage, pageSize,cri);
}
public JSONObject listPageJson(Dao dao, Class obj, Condition cnd,Pager pager) {
JSONObject jsonobj = new JSONObject();
List list = dao.query(obj, cnd, pager);
pager.setRecordCount(dao.count(obj, cnd));//记录数需手动设置
jsonobj.put("total", pager.getRecordCount());
jsonobj.put("rows", JSONArray.fromObject(list));
return jsonobj;
}
执行的sql就是:select count(*) from (select * from l_jsgg where 1=1 order by add_time desc)
这个别名加在哪里

daoCtl.listPageJson 这是自己封装的方法吧?

是的,但是关键的执行语句是这一句:dao.count(obj, cnd),是框架中的count方法,

dao.count(obj, cnd) ??? 贴语句, 用"插入代码"按钮

public JSONObject listPageJson(Dao dao, Class obj, Condition cnd,Pager pager) {
JSONObject jsonobj = new JSONObject();
List list = dao.query(obj, cnd, pager);
pager.setRecordCount(dao.count(obj, cnd));//记录数需手动设置 就是这里啊,用于查询记录条数的,因为是封装在nutz框架中的,别名我就不知道在哪加了
jsonobj.put("total", pager.getRecordCount());
jsonobj.put("rows", JSONArray.fromObject(list));
return jsonobj;
}

QueryResult qr = daoCtl.listPageSql(dao, sql, curPage, pageSize);
// 
public JSONObject listPageJson(Dao dao, Class obj, Condition cnd,Pager pager) {

这方法签名都对不上

用"插入代码"按钮贴代码啊!!!!!!!!!

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