Exemple #1
0
  public Integer getCountUserValidate(String staffPiority) {
    Criteria criteria = getSession().createCriteria(User.class);
    criteria.add(Restrictions.eq("validateStu", 0));
    criteria.add(Restrictions.like("piority", "%" + staffPiority + "%"));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.count("validateStu"));
    criteria.setProjection(projectionList);

    Integer count = (Integer) criteria.uniqueResult();
    closeSession();
    return count;
  }
Exemple #2
0
 public Plantel getPlantelById() {
   Session session = HibernateUtil.getSessionFactory().openSession();
   Plantel plantel = null;
   ProjectionList plist = Projections.projectionList();
   plist.add(Projections.property("p.nombre").as("nombre"));
   Criteria criteria =
       session
           .createCriteria(Plantel.class, "p")
           .setProjection(plist)
           .setResultTransformer(new AliasToBeanResultTransformer(Plantel.class))
           .addOrder(Order.asc("nombre"));
   plantel = (Plantel) criteria.uniqueResult();
   session.close();
   return plantel;
 }