List of usage examples for org.hibernate.criterion DetachedCriteria addOrder
public DetachedCriteria addOrder(Order order)
From source file:com.hongqiang.shop.modules.cms.service.LinkService.java
License:Open Source License
public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) { // ??6??/*from w w w .j a v a 2 s. c om*/ Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink"); if (updateExpiredWeightDate == null || (updateExpiredWeightDate != null && updateExpiredWeightDate.getTime() < new Date().getTime())) { linkDao.updateExpiredWeight(); CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6)); } DetachedCriteria dc = linkDao.createDetachedCriteria(); dc.createAlias("category", "category"); dc.createAlias("category.site", "category.site"); if (link.getCategory() != null && link.getCategory().getId() != null && !Category.isRoot(link.getCategory().getId())) { Category category = categoryDao.findOne(link.getCategory().getId()); if (category != null) { dc.add(Restrictions.or(Restrictions.eq("category.id", category.getId()), Restrictions.like("category.parentIds", "%," + category.getId() + ",%"))); dc.add(Restrictions.eq("category.site.id", category.getSite().getId())); link.setCategory(category); } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } if (StringUtils.isNotEmpty(link.getTitle())) { dc.add(Restrictions.like("title", "%" + link.getTitle() + "%")); } if (link.getCreateBy() != null && link.getCreateBy().getId() > 0) { dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId())); } if (isDataScopeFilter) { dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy"); dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy")); } dc.add(Restrictions.eq(Link.DEL_FLAG, link.getDelFlag())); dc.addOrder(Order.desc("weight")); dc.addOrder(Order.desc("updateDate")); return linkDao.find(page, dc); }
From source file:com.hongqiang.shop.modules.sys.service.DictService.java
License:Open Source License
public Page<Dict> find(Page<Dict> page, Dict dict) { DetachedCriteria dc = dictDao.createDetachedCriteria(); if (StringUtils.isNotEmpty(dict.getType())) { dc.add(Restrictions.eq("type", dict.getType())); }/*from w w w. j a v a 2s . com*/ if (StringUtils.isNotEmpty(dict.getDescription())) { dc.add(Restrictions.like("description", "%" + dict.getDescription() + "%")); } dc.add(Restrictions.eq(Dict.DEL_FLAG, Dict.DEL_FLAG_NORMAL)); dc.addOrder(Order.asc("type")).addOrder(Order.asc("sort")).addOrder(Order.desc("id")); return dictDao.find(page, dc); }
From source file:com.hongqiang.shop.modules.sys.service.SystemService.java
License:Open Source License
public Page<User> findUser(Page<User> page, User user) { DetachedCriteria dc = userDao.createDetachedCriteria(); User currentUser = UserUtils.getUser(); dc.createAlias("company", "company"); if (user.getCompany() != null && user.getCompany().getId() != null) { dc.add(Restrictions.or(Restrictions.eq("company.id", user.getCompany().getId()), Restrictions.like("company.parentIds", "%," + user.getCompany().getId() + ",%"))); }/*from ww w. j av a 2 s . com*/ dc.createAlias("office", "office"); if (user.getOffice() != null && user.getOffice().getId() != null) { dc.add(Restrictions.or(Restrictions.eq("office.id", user.getOffice().getId()), Restrictions.like("office.parentIds", "%," + user.getOffice().getId() + ",%"))); } // ???? if (!currentUser.isAdmin()) { dc.add(Restrictions.ne("id", 1L)); } dc.add(dataScopeFilter(currentUser, "office", "")); //System.out.println(dataScopeFilterString(currentUser, "office", "")); if (StringUtils.isNotEmpty(user.getLoginName())) { dc.add(Restrictions.like("loginName", "%" + user.getLoginName() + "%")); } if (StringUtils.isNotEmpty(user.getName())) { dc.add(Restrictions.like("name", "%" + user.getName() + "%")); } dc.add(Restrictions.eq(User.DEL_FLAG, User.DEL_FLAG_NORMAL)); if (!StringUtils.isNotEmpty(page.getOrderBy())) { dc.addOrder(Order.asc("company.code")).addOrder(Order.asc("office.code")).addOrder(Order.desc("id")); } return userDao.find(page, dc); }
From source file:com.hongqiang.shop.modules.sys.service.SystemService.java
License:Open Source License
public List<Role> findAllRole() { User user = UserUtils.getUser();//from w ww . ja v a 2s . com DetachedCriteria dc = roleDao.createDetachedCriteria(); dc.createAlias("office", "office"); dc.createAlias("userList", "userList", JoinType.LEFT_OUTER_JOIN); dc.add(dataScopeFilter(user, "office", "userList")); dc.add(Restrictions.eq(Role.DEL_FLAG, Role.DEL_FLAG_NORMAL)); dc.addOrder(Order.asc("office.code")).addOrder(Order.asc("name")); return roleDao.find(dc); }
From source file:com.hypersocket.auth.AuthenticationModuleRepositoryImpl.java
License:Open Source License
public List<AuthenticationModule> getAuthenticationModulesByScheme( final AuthenticationScheme authenticationScheme) { return allEntities(AuthenticationModule.class, new DeletedDetachedCriteria(false), new DistinctRootEntity(), new DetachedCriteriaConfiguration() { @Override//from w w w .j a v a 2 s. com public void configure(DetachedCriteria criteria) { criteria.add(Restrictions.eq("scheme", authenticationScheme)); criteria.addOrder(Order.asc("idx")); } }); }
From source file:com.hypersocket.repository.OrderByAsc.java
License:Open Source License
@Override public void configure(DetachedCriteria criteria) { criteria.addOrder(Order.asc(property)); }
From source file:com.hypersocket.repository.OrderByDesc.java
License:Open Source License
@Override public void configure(DetachedCriteria criteria) { criteria.addOrder(Order.desc(property)); }
From source file:com.isdemu.dao.impl.TBC_ClaseActivoDaoImpl.java
@Override public List LastCodClase(Serializable id) { DetachedCriteria dc = DetachedCriteria.forClass(TbcClaseActivo.class, "clase"); dc.createAlias("clase.tbcClasificacionActivo", "clasi"); dc.add(Restrictions.eq("clasi.idClasificacionActivo", id)); dc.addOrder(Order.desc("idClaseActivo")); return dc.getExecutableCriteria(sessionFactory.getCurrentSession()).list(); }
From source file:com.isdemu.dao.impl.TB_ControlDaoImpl.java
@Override public List LastIdControl() { DetachedCriteria dc = DetachedCriteria.forClass(TbControlSalida.class, "con"); dc.addOrder(Order.desc("idControlSalida")); return dc.getExecutableCriteria(sessionFactory.getCurrentSession()).list(); }
From source file:com.isdemu.dao.impl.TB_InventarioDaoImpl.java
@Override public List getTop() { // TODO Auto-generated method stub DetachedCriteria dc = DetachedCriteria.forClass(TbInventario.class); dc.addOrder(Order.asc("idInventario")); Date fecha_finalHoy = new Date(); Date fecha_inicial = new Date(); //restar dias a la fecha Calendar calendar = Calendar.getInstance(); calendar.setTime(fecha_finalHoy);/*from w w w .java 2 s .co m*/ calendar.add(Calendar.DAY_OF_YEAR, -7); // numero de das a aadir, o restar en caso de das<0 fecha_inicial = calendar.getTime(); dc.add(Restrictions.between("fechaInsert", fecha_inicial, fecha_finalHoy)); System.out.println("fecha inicial:" + fecha_inicial + "fecha final:" + fecha_finalHoy); return dc.getExecutableCriteria(sessionFactory.getCurrentSession()).list(); }