List of usage examples for org.hibernate Query list
List<R> list();
From source file:backend.api.Statistics.java
public List<MonitoringWorkers> getRecordsMonitoringWorkers() { Session s = sf.openSession();/*from w ww . j av a 2s .c om*/ try { Query query = s.createQuery("select m from MonitoringWorkers m"); List<MonitoringWorkers> monitor = query.list(); if (monitor.isEmpty() || monitor.size() == 0) return null; return monitor; } finally { s.close(); } }
From source file:backend.api.Statistics.java
public List<FinanceRegister> getFinanceRegisterRecords() // ok { Session s = sf.openSession();//from www. ja va2 s .c o m try { Query q = s.createQuery("select f from FinanceRegister f"); List<FinanceRegister> result = q.list(); if (result.isEmpty() || result.size() == 0) return null; return result; } catch (Exception e) { e.printStackTrace(); return null; } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public Products getProduct(int idProduct, String type) // po id // nie ma po typie, jezeli chcie to dodam { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {//from ww w . ja v a 2s. c o m Query q = s.createQuery("select p from Products p where '" + idProduct + "'=p.idProducts"); List<Products> result = q.list(); if (result.isEmpty() || result.size() == 0) return null; return (Products) result.get(0); } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public List<Products> getProducts() //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {/*from w w w .j a v a 2s. c o m*/ Query query = s.createQuery("select p from Products p"); List<Products> prod = query.list(); return prod; } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public List<Category> getCategory() //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {/* www . j a va 2 s. c om*/ Query query = s .createQuery("select new backend.core.model.Category(c.idCategory, c.name) from Category c"); List<Category> category = query.list(); return category; } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public Category getCategory(int idCategory) //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {/*from w w w . j a v a2 s . c o m*/ Query query = s.createQuery("from Category c where c.idCategory='" + idCategory + "'"); List<Category> category = query.list(); if (category.isEmpty() || category.size() == 0) return null; return (Category) category.get(0); } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public Category getCategory(String name) //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {//from ww w. ja v a 2 s.co m Query query = s.createQuery("from Category c where c.name='" + name + "'"); List<Category> category = query.list(); if (category.isEmpty() || category.size() == 0) return null; return (Category) category.get(0); } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public List<Manufacturers> getManufacturer() //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {//w w w . ja va 2s . c om Query query = s.createQuery("select m from Manufacturers m"); List<Manufacturers> manu = query.list(); return manu; } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public Manufacturers getManufacturer(String name) //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {/*from w ww . j a v a2 s .co m*/ Query query = s.createQuery("select m from Manufacturers m where m.name= '" + name + "'"); List<Manufacturers> manu = query.list(); if (manu.isEmpty() || manu.size() == 0) return null; return (Manufacturers) manu.get(0); } finally { s.close(); } }
From source file:backend.api.StorageManagement.java
public Manufacturers getManufacturer(int idManufacturer) //ok { Session s = SessionFactoryManager.INSTANCE.getSessionFactory().openSession(); try {//w w w.j a va2s . c o m Query query = s .createQuery("select m from Manufacturers m where m.idManufacturer= '" + idManufacturer + "'"); List<Manufacturers> manu = query.list(); if (manu.isEmpty() || manu.size() == 0) return null; return (Manufacturers) manu.get(0); } finally { s.close(); } }