/** * Test表根据name查询 * * @param name * @param pageNumber * @param pageSize * @return 对应考试名称的考试信息 */ public QueryResult queryByName(String name, int pageNumber, int pageSize) { Pager pager = dao().createPager(pageNumber, pageSize); List<Test> listByName = dao().query(Test.class, Cnd.where("test_name", "like", "%" + name + "%"), pager); pager.setRecordCount(dao().count(Test.class, Cnd.where("test_name", "like", "%" + name + "%"))); return new QueryResult(listByName, pager); }
public List<Topic> getRecentReplyTopics(int userId, Pager pager) { Map<Integer, UserProfile> authors = new HashMap<Integer, UserProfile>(); Cnd cnd = Cnd.where("userId", "=", userId); cnd.desc("createTime"); Sql sql = Sqls.queryString("select DISTINCT topicId from t_topic_reply $cnd") .setEntity(dao.getEntity(TopicReply.class)) .setVar("cnd", cnd); pager.setRecordCount( dao.execute( Sqls.fetchInt("select count(DISTINCT topicId) from t_topic_reply $cnd") .setEntity(dao.getEntity(TopicReply.class)) .setVar("cnd", cnd)) .getInt()); sql.setPager(pager); String[] replies_topic_ids = dao.execute(sql).getObject(String[].class); List<Topic> recent_replies = new ArrayList<Topic>(); for (String topic_id : replies_topic_ids) { Topic _topic = dao.fetch(Topic.class, topic_id); if (_topic == null) continue; recent_replies.add(_topic); } if (!recent_replies.isEmpty()) { for (Topic topic : recent_replies) { fillTopic(topic, authors); } } return recent_replies; }
@Filters(@By(type = AjaxCheckSession.class, args = "me")) @At("/update") public Object updateInfo( String nickName, String passwd, @Attr("me") User me, HttpSession session) { if (!Strings.isBlank(nickName) && !nickName.startsWith("_") // 系统默认生成的nickName以_开头 && me.getNickName().startsWith("_") // 只允许修改一次nickName && nickName.trim().length() > 1 && nickName.trim().length() < 10 && nickName.indexOf("<") < 0 && nickName.indexOf(">") < 0 && nickName.indexOf("@") < 0 && nickName.indexOf("#") < 0 && nickName.indexOf(" ") < 0 && nickName.indexOf("&") < 0) { try { dao.update( User.class, Chain.make("nickName", nickName.trim()), Cnd.where("id", "=", me.getId())); } catch (Throwable e) { return Ajax.fail().setMsg("Nickname is dup or it is BAD!"); } } if (!Strings.isBlank(passwd) && passwd.trim().length() > 5 && passwd.trim().length() < 40) { dao.update( User.class, Chain.make("passwd", xMD5(passwd.trim())), Cnd.where("id", "=", me.getId())); } session.setAttribute("me", dao.fetch(User.class, Cnd.where("id", "=", me.getId()))); return Ajax.ok(); }
public void updateTacTerminal() { /** * List<String[]> list = CvsFileParser.getCSV("厂商数据_01.csv"); for(String[] ss:list){ * if(ss.length < 3){ System.out.println(" >> "+ss[0]+"|"+ss[1]); } } */ Cnd condition = Cnd.where("d_status", "=", "1"); List<Tac> tlist = dao.search(Tac.class, condition.orderBy().asc("d_hsman_name")); for (Tac t : tlist) { List<String[]> list = CvsFileParser.getCSV("厂商数据_01.csv"); for (String[] str : list) { if (t.getHsmanName().toLowerCase().equals(str[0].toLowerCase())) { if (!"0".equals(str[1])) { t.setHsmanNameEn(str[1].toLowerCase()); } if (!"0".equals(str[2])) { t.setHsmanName(str[2].toLowerCase()); } if (dao.update(t)) { System.out.println( " >> 更新成功[" + t.getId() + "|" + t.getTac() + "|" + t.getHsmanName() + "|" + t.getHsmanNameEn() + "]"); break; } } } } }
@At @Ok("json") public JDataGrid list_grid( @Attr(scope = Scope.SESSION, value = "account") Account acc, @Param("::columns") List<?> columns, @Param("::search") Map<?, ?> search, int draw, int start, int length) { start = start / length; Pager pager = new Pager(); pager.setPageNumber(start + 1); pager.setPageSize(length); Cnd cnd = Cnd.where("accountid", "=", acc.accountid); if (!Lang.isEmpty(search.get("value")) && !search.get("value").toString().equals("")) { cnd.and("name", "like", search.get("value")); } List<?> aaData = dao.query(Store.class, cnd); pager.setRecordCount(dao.count(Store.class, cnd)); JDataGrid ret = new JDataGrid(); ret.draw = draw; ret.data = aaData; ret.recordsTotal = pager.getRecordCount(); ret.recordsFiltered = pager.getRecordCount(); return ret; }
/** * Test表查询一段时间的记录 * * @param date1 * @param date2 * @param pageNumber * @param pageSize * @return 对应一段时间内的考试信息 */ public QueryResult queryByPeriodDate(Date date1, Date date2, int pageNumber, int pageSize) { Pager pager = dao().createPager(pageNumber, pageSize); List<Test> listByPeriodDate = dao().query(Test.class, Cnd.where("Date", ">=", date1).and("Date", "<=", date2), pager); pager.setRecordCount( dao().count(Test.class, Cnd.where("Date", ">=", date1).and("Date", "<=", date2))); return new QueryResult(listByPeriodDate, pager); }
@At("/list_goodid/?") @Ok("json") public Object list_goodid(int id, @Attr(scope = Scope.SESSION, value = "account") Account acc) { Cnd cnd = Cnd.where("accountid", "=", acc.accountid); if (id != 0) { cnd.and(new Static("id in (select store_id from m_typelist where id=" + id + ")")); } List<?> aaData = dao.query(Store.class, cnd); return aaData; }
public List<Topic> getRecentTopics(int userId, Pager pager) { List<Topic> recent_topics = dao.query(Topic.class, Cnd.where("userId", "=", userId).desc("createTime"), pager); Map<Integer, UserProfile> authors = new HashMap<Integer, UserProfile>(); if (!recent_topics.isEmpty()) { for (Topic topic : recent_topics) { fillTopic(topic, authors); } } pager.setRecordCount(dao.count(Topic.class, Cnd.where("userId", "=", userId))); return recent_topics; }
@At("/passwd/reset") public void resetPassword(String email, HttpServletRequest req) { if (Strings.isBlank(email)) return; User user = dao.fetch(User.class, Cnd.where("email", "=", email)); if (user == null) return; dao.clear(PasswordReset.class, Cnd.where("uid", "=", user.getId())); String token = R.UU64() + R.UU64(); PasswordReset reset = new PasswordReset(); reset.setUid(dao.fetch(User.class, Cnd.where("email", "=", email)).getId()); reset.setToken(token); dao.insert(reset); String url = req.getRequestURL() + "/callback?token=" + token; mailService.add2Queue(email, "推爸 密码重置请求", "Reset URL --> " + url); }
@At @Ok("raw") public String tree(@Param("id") String id, HttpSession session) throws Exception { Sys_user user = (Sys_user) session.getAttribute("userSession"); id = Strings.sNull(id); List array = new ArrayList(); if ("".equals(id)) { Map<String, Object> jsonroot = new HashMap<String, Object>(); jsonroot.put("id", ""); jsonroot.put("pId", "0"); jsonroot.put("name", "机构列表"); jsonroot.put("icon", Globals.APP_BASE_NAME + "/images/icons/icon042a1.gif"); array.add(jsonroot); } Criteria cri = Cnd.cri(); if (user.getSysrole()) // 判断是否为系统管理员角色 { cri.where().and("id", "like", id + "____"); cri.getOrderBy().asc("location"); cri.getOrderBy().asc("id"); } else { if ("".equals(id)) { cri.where().and("id", "=", user.getUnitid()); cri.getOrderBy().asc("location"); cri.getOrderBy().asc("id"); } else { cri.where().and("id", "like", id + "____"); cri.getOrderBy().asc("location"); cri.getOrderBy().asc("id"); } } List<Sys_unit> unitlist = daoCtl.list(dao, Sys_unit.class, cri); int i = 0; for (Sys_unit u : unitlist) { String pid = u.getId().substring(0, u.getId().length() - 4); int num = daoCtl.getRowCount(dao, Sys_unit.class, Cnd.wrap("id like '" + u.getId() + "____'")); if (i == 0 || "".equals(pid)) pid = "0"; Map<String, Object> obj = new HashMap<String, Object>(); obj.put("id", u.getId()); obj.put("pId", pid); obj.put("name", u.getName()); obj.put("url", "javascript:view(\"" + u.getId() + "\")"); obj.put("isParent", num > 0 ? true : false); obj.put("target", "_self"); array.add(obj); i++; } return Json.toJson(array); }
public void test6() { Cnd condition = Cnd.where("d_status", "=", "1"); List<Tac> tlist = dao.search(Tac.class, condition.orderBy().asc("d_hsman_name")); for (Tac t : tlist) { // System.out.print(" > // "+t.getHsmanName()+"|"+t.getHsmanNameEn()+"|"+t.getHstypeName()+"|"+t.getHstypeNameEn()); // 如果是英文,则将中文名称制空,然后修改英文 /** * if(t.getHsmanName().matches("^[a-zA-Z]*")){ t.setHsmanName("暂无"); t.setCreatetime(new * Date()); } */ if (null != t.getHsmanNameEn() && !"".equals(t.getHsmanNameEn()) && t.getHstypeName().toLowerCase().startsWith(t.getHsmanNameEn().toLowerCase())) { String hstypename = t.getHstypeName().toLowerCase().replace(t.getHsmanNameEn().toLowerCase(), ""); if (null != hstypename) { t.setHstypeName(hstypename.trim()); System.out.println(" -> 1:" + hstypename.trim()); } } if (null != t.getHsmanName() && !"".equals(t.getHsmanName()) && t.getHstypeName().toLowerCase().startsWith(t.getHsmanName().toLowerCase())) { String hstypename = t.getHstypeName().toLowerCase().replace(t.getHsmanName().toLowerCase(), ""); if (null != hstypename) { t.setHstypeName(hstypename.trim()); System.out.println(" -> 2:" + hstypename.trim()); } } if (t.getHstypeName().startsWith("one touch ")) { String hstypename = t.getHstypeName().toLowerCase().replace("one touch ", ""); t.setHstypeName(hstypename); } String[] strs = t.getHstypeName().toLowerCase().split(" "); if (strs.length > 2) { String hsman = strs[0]; String hstype = strs[1]; System.out.println( " > [" + t.getHsmanName() + "|" + t.getHstypeName() + "] " + hsman + "|" + hstype); } /** */ // if(dao.update(t)){ // System.out.println(" >> 更新厂商名称为英文的厂商名称成功!"); // } } }
private void resourceRelationFull(Resource resource) { List<Tag> tags; Sql sql_resource = Sqls.create( "select * from tag as t, resource_tag as rt where rt.resource_id = " + resource.getId() + " and rt.tag_id = t.id"); sql_resource.setCallback(Sqls.callback.entities()); sql_resource.setEntity(dao.getEntity(Tag.class)); dao.execute(sql_resource); tags = sql_resource.getList(Tag.class); List<UserInfo> user = dao.query(UserInfo.class, Cnd.where("id", "=", resource.getAuthor())); if (user.size() > 0) { resource.setUserInfo(user.get(0)); } else { System.out.print("resourceservice:用户id无效"); } String tagString = ""; // 资源tag回填 for (int i = 0; i < tags.size(); i++) { if (i < (tags.size() - 1)) { tagString = tagString + tags.get(i).getName() + ","; } else { tagString = tagString + tags.get(i).getName(); } } resource.setTags(tagString); resource.setTagEntityList(tags); }
@At("/passwd/reset/callback") public Object resetPasswdCallback(String token) { PasswordReset reset = dao.fetch(PasswordReset.class, Cnd.where("token", "=", token)); if (reset != null) { dao.clear(PasswordReset.class, Cnd.where("token", "=", token)); if (System.currentTimeMillis() - reset.getCreateTime().getTime() > 30 * 60 * 1000) return Ajax.fail().setMsg("token is expise"); String passwd = R.sg(12).next(); dao.update( User.class, Chain.make("passwd", xMD5(passwd)), Cnd.where("id", "=", reset.getUid())); String email = dao.fetch(User.class, Cnd.where("id", "=", reset.getUid())).getEmail(); mailService.add2Queue(email, "推爸密码重置邮件", "Your password : "******"Reset success!! Check you email!"); } return Ajax.fail().setMsg("Token not found!!"); }
/** * 分页查询 * * @param phonenum * @param start * @param limit * @return */ public List<TmpGprs> search(String phonenum, String loginName, int start, int limit) throws Exception { Cnd condition = null; if (null != phonenum && !"".equals(phonenum)) { condition = Cnd.where("d_phone_number", "=", phonenum) .and("d_uid", "=", loginName.replace("weinan2", "weinan1")); // if(null != loginName && !"".equals(loginName)){ // if(loginName.equals("weinan1")){ // condition.and("d_id","<","2368"); // }else if(loginName.equals("weinan2")){ // condition.and("d_id",">","2367").and("d_id","<","4736"); // }else if(loginName.equals("weinan3")){ // condition.and("d_id",">","4735").and("d_id","<","7103"); // }else if(loginName.equals("weinan5")){ // condition.and("d_id",">","7102"); // } // } start = start / limit + 1; if (start == 0) { start = 1; } List<TmpGprs> list = tmpGprsDao.searchByPage(TmpGprs.class, condition, start, limit); return list; } else { return null; } }
private void initData() { typeData.clear(); typeData.addAll(ToolType.allToolTypes()); List<ToolsTray> bandejaList = dao.query(ToolsTray.class, Cnd.where("toolType", "=", C.TOOL_TYPE_TRAY_FOLDER)); superData.clear(); ToolsTray bandeja1 = new ToolsTray(); bandeja1.setId(C.ROOT_PARENT_ID); bandeja1.setTrayName("--无父目录--"); superData.add(bandeja1); superData.addAll(bandejaList); searchData.clear(); ToolsTray bandeja = new ToolsTray(); bandeja.setTrayName("--全部--"); searchData.add(bandeja); searchData.add(bandeja1); searchData.addAll(bandejaList); tableData.clear(); tableData.addAll(dao.query(ToolsTray.class, null)); }
private void batchDeleteParameter(String table, List<Parameter> data) { for (Parameter p : data) { int c = baseService.dao.clear(table, Cnd.where("srcTimestr", "=", p.getSrcTimestr())); } /*if(null != data || data.size() > 0){ }*/ }
/** 输出Sitemap */ @At @Ok("raw:xml") public File sitemap() throws MalformedURLException, ParseException { String tmpdir = conf.get("website.tmp_dir", "/tmp"); Files.createDirIfNoExists(tmpdir); final WebSitemapGenerator gen = new WebSitemapGenerator(urlbase, new File(tmpdir)); gen.addUrl(urlbase + "/yvr/list"); dao.each( Topic.class, Cnd.orderBy().desc("createTime"), dao.createPager(1, 1000), new Each<Topic>() { public void invoke(int index, Topic topic, int length) { try { Options options = new Options(urlbase + "/yvr/t/" + topic.getId()); // TODO 从redis读取最后更新时间 // options.lastMod(topic.getCreateAt()); WebSitemapUrl url = new WebSitemapUrl(options); gen.addUrl(url); } catch (Exception e) { e.printStackTrace(); } } }); List<File> list = gen.write(); if (list.size() > 0) return list.get(0); return null; }
@At @Ok(">>:/admin/permission/category/list.rk") @RequiresPermissions({"permission:edit"}) public boolean update(@Param("name") String name, @Param("id") String id) { permissionCategoryService.update(Chain.make("name", name), Cnd.where("id", "=", id)); return true; }
/** * @api {get} /yvr/api/v1/topic/:id 获取帖子的详细数据 * @apiGroup Topic * @apiVersion 1.0.0 * @apiParam {String} id 帖子id * @apiParam {boolean} [mdrender=true] 是否渲染Markdown * @apiSuccess {Object[]} data 帖子数据 * @apiSuccess {String} data.id 唯一标示符 * @apiSuccess {String} data.title 标题 * @apiSuccess {String} data.tab 类型 * @apiSuccess {String} data.content 内容 * @apiSuccess {String} [data.last_reply_at] 最后回复时间 * @apiSuccess {boolean} data.top 是否置顶 * @apiSuccess {boolean} data.good 是否为精华帖 * @apiSuccess {int} data.reply_count 总回复数量 * @apiSuccess {int} data.visit_count 总浏览数量 * @apiSuccess {Object} data.author 作者信息 * @apiSuccess {String} data.author.id 作者id * @apiSuccess {String} data.author.loginname 作者登陆名 * @apiSuccess {Object[]} [data.replies] 回复列表 * @apiSuccess {String} data.replies.id 回复id * @apiSuccess {String} data.replies.author 回复的作者 * @apiSuccess {String} data.replies.author.id 回复的作者的id * @apiSuccess {String} data.replies.author.loginname 回复的作者的登陆名称 * @apiSuccess {String} data.replies.content 回复的内容 * @apiSuccess {String[]} data.replies.ups 点赞数 * @apiSuccess {Object} data.replies.author 回帖作者信息 * @apiSuccess {String} data.replies.create_at 回帖时间 * @apiSuccess {String} data.replies.author.id 作者id * @apiSuccess {String} data.replies.author.loginname 作者登陆名 * @apiError 404 The <code>id</code> of the Topic was not found. */ @Aop("redis") @GET @At("/topic/?") public Object topic(String id, @Param("mdrender") String mdrender) { Topic topic = dao.fetch(Topic.class, id); if (id == null) { return HttpStatusView.HTTP_404; } NutMap tp = _topic(topic, new HashMap<Integer, UserProfile>(), mdrender); List<NutMap> replies = new ArrayList<NutMap>(); for (TopicReply reply : dao.query(TopicReply.class, Cnd.where("topicId", "=", id).asc("createTime"))) { dao.fetchLinks(reply, null); reply.setUps(jedis().zrange(RKEY_REPLY_LIKE + reply.getId(), 0, System.currentTimeMillis())); NutMap re = new NutMap(); re.put("id", reply.getId()); re.put("author", _author(reply.getAuthor())); re.put( "content", "false".equals(mdrender) ? reply.getContent() : Markdowns.toHtml(reply.getContent(), urlbase)); re.put("ups", new ArrayList<String>(reply.getUps())); re.put("create_at", _time(reply.getCreateTime())); replies.add(re); } tp.put("replies", replies); jedis().zincrby(RKEY_TOPIC_VISIT, 1, topic.getId()); return _map("data", tp); }
@Override public boolean updateImgCommentId(long userId, long skuId, List<Long> imgList, long commentId) { Chain chn = Chain.make("commentId", commentId); Condition cnd = Cnd.where("id", "in", imgList).and("userId", "=", userId).and("skuId", "=", skuId); return 1 == dao.update(SkuCommentImg.class, chn, cnd); }
@At @Ok("json") public Object list(@Attr(scope = Scope.SESSION, value = "account") Account acc) { Cnd cnd = Cnd.where("accountid", "=", acc.accountid); List<?> aaData = dao.query(Store.class, cnd); return aaData; }
/** * 根据指定的字段模糊分页查询数据 记录总数 * * @param <T> * @param c 查询的表 * @param fieldName 字段名称 * @param value 模糊条件 * @param currentPage 当前页码 * @param pageSize 每页数据量 * @return List */ public <T> int searchByPageLike(Class<T> c, String fieldName, String value) { Entity<T> entity = dao.getEntity(c); String column = entity.getField(fieldName).getColumnName(); return dao.count(c, Cnd.where(column, "LIKE", "%" + value + "%")); }
/** * 根据多个id 查询数据 * * @param <T> * @param ids 整形的id数组 * @param c 要查询的表信息 * @return List */ public <T> List<T> searchByIds(Class<T> c, int[] ids, String orderby) { Entity<T> entity = dao.getEntity(c); String id = entity.getIdField().getColumnName(); return dao.query(c, Cnd.where(id, "in", ids).desc(orderby), null); }
@Aop("redis") public CResult add(Topic topic, int userId) { if (userId < 1) { return _fail("请先登录"); } if (Strings.isBlank(topic.getTitle()) || topic.getTitle().length() > 1024 || topic.getTitle().length() < 5) { return _fail("标题长度不合法"); } if (Strings.isBlank(topic.getContent())) { return _fail("内容不合法"); } if (topic.getTags() != null && topic.getTags().size() > 10) { return _fail("最多只能有10个tag"); } if (0 != dao.count(Topic.class, Cnd.where("title", "=", topic.getTitle().trim()))) { return _fail("相同标题已经发过了"); } topic.setTitle(Strings.escapeHtml(topic.getTitle().trim())); topic.setUserId(userId); topic.setTop(false); topic.setTags(new HashSet<String>()); if (topic.getType() == null) topic.setType(TopicType.ask); topic.setContent(Toolkit.filteContent(topic.getContent())); String oldContent = topic.getContent(); topic.setContentId(bigContentService.put(topic.getContent())); topic.setContent(null); dao.insert(topic); try { topic.setContent(oldContent); topicSearchService.add(topic); } catch (Exception e) { } // 如果是ask类型,把帖子加入到 "未回复"列表 Pipeline pipe = jedis().pipelined(); if (TopicType.ask.equals(topic.getType())) { pipe.zadd(RKEY_TOPIC_NOREPLY, System.currentTimeMillis(), topic.getId()); } pipe.zadd(RKEY_TOPIC_UPDATE + topic.getType(), System.currentTimeMillis(), topic.getId()); if (topic.getType() != TopicType.shortit) pipe.zadd(RKEY_TOPIC_UPDATE_ALL, System.currentTimeMillis(), topic.getId()); pipe.zincrby(RKEY_USER_SCORE, 100, "" + userId); pipe.sync(); String replyAuthorName = dao.fetch(User.class, userId).getName(); for (Integer watcherId : globalWatcherIds) { if (watcherId != userId) pushUser( watcherId, "新帖:" + topic.getTitle(), topic.getId(), replyAuthorName, topic.getTitle(), PushService.PUSH_TYPE_REPLY); } updateTopicTypeCount(); return _ok(topic.getId()); }
@At public Object login(String email, String passwd, HttpServletRequest req) { if (Strings.isBlank(email) || Strings.isBlank(passwd)) return Ajax.fail(); User me = dao.fetch(User.class, Cnd.where("email", "=", email).and("passwd", "=", xMD5(passwd))); if (me == null) return Ajax.fail(); req.getSession().setAttribute("me", me); return Ajax.ok(); }
/** * 根据多个id 查询数据 * * @param <T> * @param ids 要查询的id,多个用","(逗号)分隔 * @param c 要查询的表信息 * @return List */ public <T> List<T> searchByIds(Class<T> c, String ids, String orderby) { Entity<T> entity = dao.getEntity(c); String id = entity.getIdField().getColumnName(); String sql = " " + id + " in (" + ids + ") order by " + orderby + " desc"; return dao.query(c, Cnd.wrap(sql), null); }
/** * 根据多个id 查询数据条数 * * @param <T> * @param ids 要查询的id,多个用","(逗号)分隔 * @param c 要查询的表信息 * @return List */ public <T> int searchByIdsCount(Class<T> c, String ids, String orderby) { Entity<T> entity = dao.getEntity(c); String id = entity.getIdField().getColumnName(); String sql = " " + id + " in (" + ids + ") order by " + orderby + " desc"; return dao.count(c, Cnd.wrap(sql)); }
/** * 分页查找 resource * * @param categoryId 分类id好好 * @param order * @param pager * @return */ public List<Resource> search(Integer categoryId, Integer tagId, String order, Pager pager) { List<Resource> query = null; if (categoryId != null) { query = dao.query(Resource.class, Cnd.where("categoryId", "=", categoryId).desc("id"), pager); if (pager != null) { pager.setRecordCount(dao.count(Resource.class, Cnd.where("categoryId", "=", categoryId))); } } else { query = dao.query(Resource.class, Cnd.orderBy().desc("id"), pager); if (pager != null) { pager.setRecordCount(dao.count(Resource.class)); } } for (Resource resource : query) { resourceRelationFull(resource); } return query; }
/** * 根据某个条件分页查询数据 * * @param <T> * @param c 查询的表 * @param fieldName 匹配字段名 * @param value 匹配的值 * @param currentPage 当前页码 * @param pageSize 每页数据量 * @return List */ public <T> List<T> searchByPage( Class<T> c, String fieldName, String value, int currentPage, int pageSize) { Entity<T> entity = dao.getEntity(c); String column = entity.getField(fieldName).getColumnName(); Pager pager = dao.createPager(currentPage, pageSize); return dao.query(c, Cnd.where(column, "=", value), pager); }
@At("/f/list") @Ok("ftl:forum/list") public Object list(String page, String pageSize) { OrderBy cnd = Cnd.orderBy().desc("createTime"); List<ForumTip> list = dao.query(ForumTip.class, cnd, null); for (ForumTip forumTip : list) { dao.fetchLinks(forumTip, null); } System.out.println(list.size()); return list; }