private DetachedCriteria makeCriteria(Map<String, Object> condition) {
        DetachedCriteria criteria = DetachedCriteria.forClass(Class.class);

        if (condition == null) {
            return criteria;
        }

        criteria.createAlias("grade", "g");
        criteria.createAlias("g.specialty", "s");
        criteria.createAlias("s.college", "c");

        if (condition.containsKey("college_id")) {
            criteria.add(Restrictions.eq("c.id", condition.get("college_id")));
        } else if (condition.containsKey("specialty_id")) {
            criteria.add(Restrictions.eq("s.id", condition.get("specialty_id")));
        } else if (condition.containsKey("grade_id")) {
            criteria.add(Restrictions.eq("g.id", condition.get("grade_id")));
        }

        if (condition.containsKey("class_name")) {
            criteria.add(Restrictions.ilike("className", condition.get("class_name").toString(), MatchMode.ANYWHERE));
        }

        return criteria;
    }