List of usage examples for org.hibernate Query list
List<R> list();
From source file:Beans.CineBeans.java
public void VerC() { session.close();//from w w w . java 2s.c o m session = HibernateUtil.getSessionFactory().openSession(); Transaction t = null; try { String consulta = "from Ciudad"; Query query = session.createQuery(consulta); lista2 = query.list(); } catch (HibernateException ex) { if (t != null) { t.rollback(); } } finally { session.flush(); session.close(); } }
From source file:Beans.CineBeans.java
public String Ver() { session = HibernateUtil.getSessionFactory().openSession(); Transaction t = null;// ww w. j av a 2s . c om try { String consulta = "from Cine"; Query query = session.createQuery(consulta); lista = query.list(); } catch (HibernateException ex) { if (t != null) { t.rollback(); } } finally { session.flush(); session.close(); } return "cineLista.xhtml"; }
From source file:Beans.CiudadBeans.java
public void Ver() { Transaction t = null;//from ww w . j a v a 2 s . c om try { t = session.beginTransaction(); String consulta = "from Ciudad"; Query query = session.createQuery(consulta); Lista = query.list(); } catch (HibernateException ex) { if (t != null) { t.rollback(); } } finally { session.flush(); session.close(); } }
From source file:beans.Controller.java
public String inicijalizujStranicu() { if (tipObavestenja == null) { petObavestenja.clear();/*from www . j a v a2s . c o m*/ session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Obavestenje WHERE arhivirano=0"); obavestenjaSva = q.list(); session.close(); ukupnoStrana = obavestenjaSva.size() / 5; strana = 1; if (obavestenjaSva.size() % 5 > 0) { ukupnoStrana++; } for (int i = 0; i < 5; i++) { petObavestenja.add(obavestenjaSva.get(i)); } return "obavestenja.xhtml"; } return "obavestenja.xhtml"; }
From source file:beans.Controller.java
public void dohvSvaObavestenja() { if (tipObavestenja == null) { session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Obavestenje WHERE arhivirano=0"); obavestenjaSva = q.list(); session.close();//from w ww . j a v a 2 s . c o m } }
From source file:beans.Controller.java
public void pretraziObavestenja(ValueChangeEvent e) { if (e.getNewValue() != null) { if (e.getNewValue().equals("sve")) { petObavestenja.clear();// www. j av a 2 s .c o m session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Obavestenje WHERE arhivirano=0"); obavestenjaSva = q.list(); session.close(); } else { petObavestenja.clear(); session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Obavestenje WHERE tip=:t AND arhivirano=0"); q.setParameter("t", e.getNewValue()); obavestenjaSva = q.list(); session.close(); } ukupnoStrana = obavestenjaSva.size() / 5; strana = 1; if (obavestenjaSva.size() % 5 > 0) { ukupnoStrana++; } if (obavestenjaSva.size() >= 5) { for (int i = 0; i < 5; i++) { petObavestenja.add(obavestenjaSva.get(i)); } } else { for (int i = 0; i < obavestenjaSva.size(); i++) { petObavestenja.add(obavestenjaSva.get(i)); } } } }
From source file:beans.Controller.java
public void promeniStranu(ValueChangeEvent e) { if (tipObavestenja == null || tipObavestenja.equals("") || tipObavestenja.equals("sve")) { session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Obavestenje WHERE arhivirano=0"); obavestenjaSva = q.list(); session.close();//from w ww . ja v a 2s .c om } else { session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Obavestenje WHERE tip=:t AND arhivirano=0"); q.setParameter("t", tipObavestenja); obavestenjaSva = q.list(); session.close(); } petObavestenja.clear(); strana = (int) e.getNewValue(); if (strana < ukupnoStrana) { int j = 0; for (int i = (strana * 5) - 5; i < (strana * 5); i++) { petObavestenja.add(obavestenjaSva.get(i)); j++; } } else { int j = 0; for (int i = (strana * 5) - 5; i < obavestenjaSva.size(); i++) { petObavestenja.add(obavestenjaSva.get(i)); j++; } } }
From source file:Beans.DirectorBeans.java
public void Ver() { Transaction t = null;/*from ww w .j a v a2 s .com*/ try { t = session.beginTransaction(); String consulta = "from Director"; Query query = session.createQuery(consulta); lista = query.list(); } catch (HibernateException ex) { if (t != null) { t.rollback(); } } finally { session.flush(); session.close(); } }
From source file:beans.NastavniciControler.java
public String detalji(String ime) { String[] niz = new String[2]; if (ime != null && !ime.equals("")) { niz = ime.split("_"); session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Korisnik WHERE ime=:i AND prezime=:p"); q.setParameter("i", niz[0]); q.setParameter("p", niz[1]); List<Korisnik> temp = new ArrayList<Korisnik>(); temp = q.list(); session.close();//from w w w . j a v a2 s . c om if (temp.size() > 0) { nastavnik = temp.get(0); } else { poruka = "Ne postoji stranica za trazenog profesora"; return "informacijeProfesor.xhtml"; } } return "nastavnikDetalji.xhtml"; }
From source file:beans.NastavniciControler.java
public void dohvKurseve() { session = dbFactory.getFactory().openSession(); Query q = session.createQuery("FROM Predavac_kurs WHERE predavac=:id"); q.setParameter("id", nastavnik.getIDKor()); kursevi_drzi = q.list(); session.close();//from w ww. j a va 2s. com if (kursevi_drzi.size() > 0) { dohvSveKurseve(); for (int i = 0; i < kursevi_drzi.size(); i++) { for (int j = 0; j < kurseviSvi.size(); j++) { if (kursevi_drzi.get(i).getKurs() == kurseviSvi.get(j).getIDKurs()) { kursevi.add(kurseviSvi.get(j)); } } } for (int i = 0; i < kursevi.size(); i++) { if (kursevi.get(i).getTip().equals("izborni")) { izborni.add(kursevi.get(i)); } else { obavezni.add(kursevi.get(i)); } } } }