예제 #1
0
 /* (non-Javadoc)
  * @see com.icss.hit.bean.interfaces.MeetingRoomDao#getRoomReg(long)
  */
 public RoomReg getRoomRegByID(long rrId) {
   Session sess = HibernateSessionFactory.getSession();
   Transaction tx = null;
   String hql = "from RoomReg rr inner join rr.sysUser u inner join rr.room r where rr.rrId = ?";
   try {
     tx = sess.beginTransaction();
     List l = sess.createQuery(hql).setLong(0, rrId).list();
     tx.commit();
     Iterator it = l.iterator();
     if (it.hasNext()) {
       Object[] obj = (Object[]) it.next();
       RoomReg rr = (RoomReg) obj[0];
       SysUser u = (SysUser) obj[1];
       Room r = (Room) obj[2];
       rr.setSysUser(u);
       rr.setRoom(r);
       return rr;
     }
     return null;
   } catch (Exception e) {
     tx.rollback();
     e.printStackTrace();
     return null;
   } finally {
     sess.close();
   }
 }
예제 #2
0
 public List<RoomReg> getAllUnsettledRoom() {
   Session sess = HibernateSessionFactory.getSession();
   Transaction tx = null;
   String hql =
       "from RoomReg rr inner join rr.room r inner join rr.sysUser u where rr.rrPass = null";
   try {
     tx = sess.beginTransaction();
     List l = sess.createQuery(hql).list();
     tx.commit();
     Iterator it = l.iterator();
     List<RoomReg> list = new ArrayList<RoomReg>();
     while (it.hasNext()) {
       Object[] obj = (Object[]) it.next();
       RoomReg rr = (RoomReg) obj[0];
       Room r = (Room) obj[1];
       SysUser u = (SysUser) obj[2];
       rr.setRoom(r);
       rr.setSysUser(u);
       list.add(rr);
     }
     return list;
   } catch (Exception e) {
     tx.rollback();
     e.printStackTrace();
     return null;
   } finally {
     sess.close();
   }
 }