List of usage examples for org.hibernate Query list
List<R> list();
From source file:backend.api.StorageManagement.java
public List<Attributes> getAttributes() //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {// w w w. j a va 2 s .c om Query query = s.createQuery("select a from Attributes a"); List<Attributes> attributes = query.list(); return attributes; } catch (Exception e) { e.printStackTrace(); return null; } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public Category getAttributes(int idAttributes) //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {/* www . ja v a2 s. c o m*/ Query query = s.createQuery("select a from Attributes a where a.idCategory='" + idAttributes + "'"); List<Category> category = query.list(); if (category.isEmpty() || category.size() == 0) return null; return (Category) category.get(0); } catch (Exception e) { e.printStackTrace(); return null; } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public Category getAttributes(String name) //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {//from w ww. j ava 2s. c om Query query = s.createQuery("select a from Attributes a where a.name='" + name + "'"); List<Category> category = query.list(); if (category.isEmpty() || category.size() == 0) return null; return (Category) category.get(0); } catch (Exception e) { e.printStackTrace(); return null; } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public List<FinanceRegister> getFinanceRegisterRecords() // ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {//from w w w . java 2 s . com Query query = s.createQuery("select fr from FinanceRegister fr"); List<FinanceRegister> fr = query.list(); return fr; } catch (Exception e) { e.printStackTrace(); return null; } finally { s.close(); } }
From source file:backend.api.View.java
public boolean checkAuthorization(String name, String password) // ok { Session s = sf.openSession();//from w w w. j av a 2 s . co m try { Query q = s.createQuery( "select u from Users u where u.name='" + name + "' and u.password='" + password + "'"); List<Users> result = q.list(); if (result.isEmpty() || result.size() == 0) return false; return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { s.close(); } }
From source file:backend.api.View.java
public List<Users> getAllUsers() // ok { Session s = sf.openSession();//w ww .ja v a 2 s .c o m try { Query query = s.createQuery("select u from Users u"); List<Users> users = query.list(); return users; } catch (Exception e) { e.printStackTrace(); return null; } finally { s.close(); } }
From source file:backend.core.controller.UserController.java
public Users getUsersByGroupId(int id) { Users user;/* w ww . java2s . c o m*/ Session s = getInstance().openSession(); try { //pracownik = (Pracownik) s.load(Pracownik.class, id); Query query = s.createQuery("select u from Users u where " + "idusers = " + id); user = (Users) query.list().get(0); } finally { s.close(); } return user; }
From source file:baking.dao.BaseDao.java
License:Open Source License
/** * HQL?./*from w w w .j a v a2s . co m*/ * * @param hql * @param values ? * @return list */ public List find(final String hql, final Object[] values) { try { Session session = getSession(); Query query = session.createQuery(hql); for (int i = 0; i < values.length; i++) { query.setParameter(i, values[i]); } return query.list(); } catch (RuntimeException re) { throw re; } }
From source file:baza.Broker.java
public ArrayList<Lekar> vratiSveLekare() { Session session = Test.getSessionFactory().openSession(); ArrayList<Lekar> lista = null; try {/* ww w . j a v a 2s. c om*/ session.beginTransaction(); Query q = session.createQuery("from Lekar"); lista = (ArrayList<Lekar>) q.list(); session.getTransaction().commit(); } catch (HibernateException hibernateException) { session.getTransaction().rollback(); } finally { session.close(); } return lista; }
From source file:baza.Broker.java
public List<Pacijent> vratiSvePacijente() { Session session = Test.getSessionFactory().openSession(); List<Pacijent> lista = null; try {//from w w w . j a va 2 s. c o m session.beginTransaction(); Query q = session.createQuery("from Pacijent"); lista = (ArrayList<Pacijent>) q.list(); session.getTransaction().commit(); } catch (HibernateException hibernateException) { session.getTransaction().rollback(); } finally { session.close(); } return lista; }