List of usage examples for org.hibernate Query list
List<R> list();
From source file:baza.Broker.java
public ArrayList<Opstina> vratiOpstine() { Session session = Test.getSessionFactory().openSession(); ArrayList<Opstina> opstine = null; try {//www . j ava 2 s.c om session.beginTransaction(); Query q = session.createQuery("from Opstina"); opstine = (ArrayList<Opstina>) q.list(); session.getTransaction().commit(); } catch (HibernateException hibernateException) { session.getTransaction().rollback(); } finally { session.close(); } return opstine; }
From source file:baza.Broker.java
public ArrayList<Tippregleda> vratiTipovePregleda() { Session session = Test.getSessionFactory().openSession(); ArrayList<Tippregleda> tipovi = null; try {/* w ww . ja v a2 s . c o m*/ session.beginTransaction(); Query q = session.createQuery("from Tippregleda"); tipovi = (ArrayList<Tippregleda>) q.list(); session.getTransaction().commit(); } catch (HibernateException hibernateException) { session.getTransaction().rollback(); } finally { session.close(); } return tipovi; }
From source file:baza.Broker.java
public List<PregledWeb> vratiPregledePacijenta(String jmbg) { Session session = Test.getSessionFactory().openSession(); ArrayList<Pregled> pregledi = null; try {/* www . ja v a2 s. com*/ session.beginTransaction(); Query q = session.getNamedQuery("Pregled.findByPacijent").setString("pacijent", jmbg); List result = q.list(); pregledi = (ArrayList<Pregled>) result; session.getTransaction().commit(); } catch (Exception e) { session.getTransaction().rollback(); } // for (Pregled pregledi1 : pregledi) { // Query qu = session.getNamedQuery("Nalaz.findByPregled").setInteger("pregled", pregledi1.getPregledPK().getBrojPregleda()); // List result1 = qu.list(); // ArrayList<Nalaz> nalazi=(ArrayList<Nalaz>) result1; // pregledi1.setNalazList(nalazi); // } // finally { session.close(); } List<PregledWeb> preglediweb = new ArrayList<PregledWeb>(); for (Pregled pregled : pregledi) { PregledWeb prw = new PregledWeb(); prw.setLekar(pregled.getLekar1()); prw.setPacijent(pregled.getPacijent1()); PregledPKWeb prwpk = new PregledPKWeb(); prwpk.setBrojPregleda(pregled.getPregledPK().getBrojPregleda()); prwpk.setLekar(pregled.getPregledPK().getLekar()); prwpk.setPacijent(pregled.getPregledPK().getPacijent()); prw.setBrojPregleda(pregled.getPregledPK().getBrojPregleda()); prw.setDatum(pregled.getDatum()); prw.setPregledpk(prwpk); prw.setTippregleda(pregled.getTipPregleda()); preglediweb.add(prw); } return preglediweb; }
From source file:baza.Broker.java
public List<NalazWeb> vratiNalaze(int pregled) { Session session = Test.getSessionFactory().openSession(); ArrayList<Nalaz> nalazi = null; try {// w w w. ja va 2 s. com session.beginTransaction(); Query q = session.getNamedQuery("Nalaz.findByPregled").setInteger("pregled", pregled); List result = q.list(); nalazi = (ArrayList<Nalaz>) result; session.getTransaction().commit(); } catch (Exception e) { session.getTransaction().rollback(); } finally { session.close(); } List<NalazWeb> lista = new ArrayList<NalazWeb>(); for (Nalaz nalaz : nalazi) { NalazWeb n = new NalazWeb(); NalazPKWeb npk = new NalazPKWeb(); npk.setBrojPregleda(nalaz.getNalazPK().getPregled()); npk.setRedniBroj(nalaz.getNalazPK().getRedniBroj()); npk.setLekar(nalaz.getNalazPK().getLekar()); n.setNalazpk(npk); n.setTegobe(nalaz.getTegobe()); n.setPredlozenaTerapija(nalaz.getPredlozenaTerapija()); n.setRedniBroj(nalaz.getNalazPK().getRedniBroj()); lista.add(n); } return lista; }
From source file:baza.Broker.java
public Pregled vratiPregled(int pregled) { Session session = Test.getSessionFactory().openSession(); Pregled p = null;/*www . j a va2 s . com*/ try { session.beginTransaction(); Query q = session.getNamedQuery("Pregled.findByBrojPregleda").setInteger("brojPregleda", pregled); p = (Pregled) q.list().get(0); } catch (Exception e) { session.getTransaction().rollback(); } finally { session.close(); } return p; }
From source file:bbdd.Administrador_DAO.java
public static List queryAdministrador_(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From bbdd.Administrador_ as Administrador_"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {// w ww .j a v a 2 s . c om Query query = session.createQuery(sb.toString()); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:bbdd.Administrador_DAO.java
public static List queryAdministrador_(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From bbdd.Administrador_ as Administrador_"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {// w ww . ja va 2 s . c om Query query = session.createQuery(sb.toString()); query.setLockMode("this", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:bbdd.ConfiguracionDAO.java
public static List queryConfiguracion(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From bbdd.Configuracion as Configuracion"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {//w w w. j a v a 2 s . co m Query query = session.createQuery(sb.toString()); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:bbdd.ConfiguracionDAO.java
public static List queryConfiguracion(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From bbdd.Configuracion as Configuracion"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {//from www . j a va 2s .co m Query query = session.createQuery(sb.toString()); query.setLockMode("this", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:bbdd.Gestor_de_Juegos__DAO.java
public static List queryGestor_de_Juegos__(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From bbdd.Gestor_de_Juegos__ as Gestor_de_Juegos__"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*w w w . ja v a 2 s. co m*/ Query query = session.createQuery(sb.toString()); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }