@Override public List<E> findBy(AOrder order, TextureBoardDefPair pair) { SearchFilter searchFilter = SearchFilter.instanceUnbound(); searchFilter.eq(order, AOrderBoardDetail.PROPERTY_orderItem, OrderItem.PROPERTY_order); searchFilter.eq(AOrderBoardDetail.PROPERTY_priceAware, pair.getBoardDef()); searchFilter.eq(AOrderBoardDetail.PROPERTY_priced, pair.getTexture()); return loadAll(searchFilter); }
@Override public List<Board> findMinFreeRestBoardsBy( Dimension detailSize, TextureBoardDefPair pair, int maxCount) { Criteria execCriteria = createCriteria(getPersistentClass()); execCriteria.add(isNull("order")); execCriteria.add(eq(Board.PROPERTY_priceAware, pair.getBoardDef())); execCriteria.add(eq(Board.PROPERTY_priced, pair.getTexture())); execCriteria.add(ge("length", new Long(detailSize.getWidth()))); execCriteria.add(ge("width", new Long(detailSize.getHeight()))); // только остатки, целые листы берем потом execCriteria.add( or( lt("length", new Long(pair.getBoardDef().getDefaultLength())), lt("width", new Long(pair.getBoardDef().getDefaultWidth())))); execCriteria.add(ge("amount", 1)); execCriteria.add(eq("status", StoreElementStatus.exist)); execCriteria.addOrder(org.hibernate.criterion.Order.asc("length")); execCriteria.addOrder(org.hibernate.criterion.Order.asc("width")); execCriteria.addOrder(org.hibernate.criterion.Order.desc("amount")); execCriteria.addOrder(org.hibernate.criterion.Order.desc("price")); execCriteria.setMaxResults(maxCount); return execCriteria.list(); }