コード例 #1
0
ファイル: QueryUserDomain.java プロジェクト: peemzas/src
  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;
  }
コード例 #2
0
ファイル: PlantelDAO.java プロジェクト: gomezhyuuga/SiRASS
 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;
 }