// hibernate 返回对象指定属性,需要返回的列,可以直接返回 对象属性 @Override public TeamPlan getTeamPlanByBaoMingId(String baomingid){ Criteria cr=this.getSession().createCriteria(BaoMingInfo.class); cr.setProjection(Projections.property("teamplan"));// 需要返回的列,可以直接返回 对象属性 cr.add(Restrictions.eq("id", baomingid));//条件 return (TeamPlan)cr.uniqueResult(); } @Override public Integer getSumBaseXuNiZuoWeiByTpid(String teamPlanID){ String hql="select sum(basexunizuoweishu) from TeamPlanXuNiZuoWeiEntity where teamplanid=:teamplanid"; Query query=this.getSession().createQuery(hql); query.setString("teamplanid", teamPlanID); return (Integer)query.uniqueResult(); }