Пример #1
0
 public Pc PcByIP(String ip) {
   Session session = HibernateUtil.getSessionFactory().openSession();
   Transaction t = session.beginTransaction();
   Query q = session.createQuery("from Pc as s where  s.pcIp='" + ip + "'");
   List lista = q.list();
   Pc pc;
   try {
     pc = (Pc) lista.listIterator().next();
   } catch (Exception e) {
     return null;
   }
   t.commit();
   return pc;
 }
Пример #2
0
 @Override
 public void update(Object pca) throws Exception {
   Pc pc = (Pc) pca;
   Session session = HibernateUtil.getSessionFactory().openSession();
   Transaction t;
   try {
     t = session.beginTransaction();
     session.merge(pc);
     t.commit();
   } catch (Exception e) {
     t = session.beginTransaction();
     t.rollback();
     throw new Exception("");
   }
 }
Пример #3
0
 public List<Pc> pcXLabortorio(long idLab) {
   Session session = HibernateUtil.getSessionFactory().openSession();
   List lista = session.createQuery("from Pc as p where p.laboratorio.labId=" + idLab).list();
   return lista;
 }
Пример #4
0
 @Override
 public List<Pc> list() {
   Session session = HibernateUtil.getSessionFactory().openSession();
   List lista = session.createQuery("from Pc").list();
   return lista;
 }
Пример #5
0
 @Override
 public Pc getByID(long id) {
   Session session = HibernateUtil.getSessionFactory().openSession();
   return (Pc) session.load(Pc.class, id);
 }