@SuppressWarnings("unchecked") @Override public Map<String, List<NoticeModel>> getTop5Notice() throws ServiceException { // TODO Auto-generated method stub Map<String, List<NoticeModel>> noticeMap = new LinkedHashMap<String, List<NoticeModel>>(); int countMax = 5; DetachedCriteria criteria = DetachedCriteria.forClass(DirectoryModel.class); String type = "news"; criteria.add(Restrictions.eq("type", type)); List<DirectoryModel> directoryList = directoryDAO.getListByCriteria(criteria); if (directoryList != null && directoryList.size() > 0) { for (DirectoryModel model : directoryList) { DetachedCriteria criteria2 = DetachedCriteria.forClass(NoticeModel.class); if (StringUtils.isNotEmpty(model.getName())) criteria2.add(Restrictions.eq("type", model.getName())); List<NoticeModel> list = noticeDAO.getListByCriteria(criteria2); List<NoticeModel> top5List = new ArrayList<NoticeModel>(); for (int i = 0; i < list.size() && i < countMax; i++) { top5List.add(list.get(i)); } noticeMap.put(model.getName(), top5List); } } return noticeMap; }