List of usage examples for org.hibernate SQLQuery list
List<R> list();
From source file:com.neu.web.phmis.dao.AdminDao.java
public String authenticate(String username, String password) { String flag = "0"; try {/*from w w w . j a v a2 s. c o m*/ session = HibernateUtil.getSessionFactory().openSession(); SQLQuery query = session .createSQLQuery("SELECT COUNT(*) FROM admin WHERE username = :user AND password = :pass"); query.setString("user", username); query.setString("pass", password); List<BigInteger> list = query.list(); int count = list.get(0).intValue(); if (count == 1) { flag = "1"; } } catch (HibernateException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return flag; } }
From source file:com.neu.web.phmis.dao.DoctorDao.java
public void createRequest(SurgeryRequestBean surgeryRequestBean) { try {//from w w w . java 2 s . c o m surgeryBean = surgeryRequestBean.getSurgeryBean(); List<ProductBean> requestedProducts = surgeryRequestBean.getRequestedProducts(); session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); SQLQuery query = session.createSQLQuery( "CALL createSurgeryRequest(:userId, :surgeryType, :patientName, :requestNo, :requestTypeId, :requestStatusId, :dateFrom, :dateTo, :instru, :staff)"); query.setInteger("userId", surgeryBean.getDoctor().getId()); query.setString("surgeryType", surgeryBean.getType()); query.setString("patientName", surgeryBean.getPatientName()); query.setString("requestNo", surgeryRequestBean.getNumber()); query.setInteger("requestTypeId", surgeryRequestBean.getTypeId()); query.setInteger("requestStatusId", surgeryRequestBean.getStatusId()); query.setDate("dateFrom", surgeryRequestBean.getDateFrom()); query.setDate("dateTo", surgeryRequestBean.getDateTo()); query.setString("instru", surgeryRequestBean.getSpecialInstructions()); query.setInteger("staff", surgeryRequestBean.getStaffCount()); List<Integer> list = query.list(); surgeryRequestBean.setId(list.get(0)); for (ProductBean p : requestedProducts) { query = session.createSQLQuery("INSERT INTO productrequested VALUES (:requestId, :productId)"); query.setInteger("requestId", surgeryRequestBean.getId()); query.setInteger("productId", p.getId()); query.executeUpdate(); } session.getTransaction().commit(); } catch (HibernateException e) { session.getTransaction().rollback(); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } }
From source file:com.neu.web.phmis.dao.InitDao.java
private List<Object[]> getEnterpriseType() { List<Object[]> resultSet = null; try {/*from w w w .j av a 2 s .c o m*/ SQLQuery query = session.createSQLQuery("SELECT * FROM enterprisetype"); resultSet = query.list(); } catch (Exception e) { e.printStackTrace(); } finally { return resultSet; } }
From source file:com.neu.web.phmis.dao.InitDao.java
private List<Object[]> getRequestType() { List<Object[]> resultSet = null; try {/*from www . j av a 2 s . c o m*/ SQLQuery query = session.createSQLQuery("SELECT * FROM requesttype"); resultSet = query.list(); } catch (Exception e) { e.printStackTrace(); } finally { return resultSet; } }
From source file:com.neu.web.phmis.dao.InitDao.java
private List<Object[]> getPaymentType() { List<Object[]> resultSet = null; try {/*from w w w . ja v a2 s . c o m*/ SQLQuery query = session.createSQLQuery("SELECT * FROM paymenttype"); resultSet = query.list(); } catch (Exception e) { e.printStackTrace(); } finally { return resultSet; } }
From source file:com.neu.web.phmis.dao.InitDao.java
private List<Object[]> getAddressType() { List<Object[]> resultSet = null; try {//from www.j a v a 2 s . co m SQLQuery query = session.createSQLQuery("SELECT * FROM addresstype"); resultSet = query.list(); } catch (Exception e) { e.printStackTrace(); } finally { return resultSet; } }
From source file:com.neu.web.phmis.dao.InitDao.java
private List<Object[]> getContactType() { List<Object[]> resultSet = null; try {/*from w w w .j ava 2s . c o m*/ SQLQuery query = session.createSQLQuery("SELECT * FROM contacttype"); resultSet = query.list(); } catch (Exception e) { e.printStackTrace(); } finally { return resultSet; } }
From source file:com.neu.web.phmis.dao.InitDao.java
private List<Object[]> getCounties() { List<Object[]> resultSet = null; try {//w ww. j ava 2s .co m SQLQuery query = session.createSQLQuery("SELECT id, name FROM county"); resultSet = query.list(); } catch (Exception e) { e.printStackTrace(); } finally { return resultSet; } }
From source file:com.neu.web.phmis.dao.InitDao.java
private List<Object[]> getRequestStatus() { List<Object[]> resultSet = null; try {/*from w w w. j av a 2 s.c o m*/ SQLQuery query = session.createSQLQuery("SELECT * FROM requeststatus"); resultSet = query.list(); } catch (Exception e) { e.printStackTrace(); } finally { return resultSet; } }
From source file:com.neu.web.phmis.dao.ResourceDao.java
public int getRequestCounts() { int counts = 0; try {/*from w w w.ja v a 2 s . c o m*/ session = HibernateUtil.getSessionFactory().openSession(); SQLQuery query = session.createSQLQuery( "SELECT COUNT(id) FROM request WHERE typeId = (SELECT typeId FROM requestType WHERE type = :type)"); query.setString("type", RequestBean.SURGERY); List<BigInteger> list = query.list(); counts = list.get(0).intValue(); } catch (HibernateException e) { session.getTransaction().rollback(); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return counts; } }