List of usage examples for org.hibernate Query setEntity
@Deprecated @SuppressWarnings("unchecked") Query<R> setEntity(String name, Object val);
From source file:com.neu.web.phmis.dao.DoctorDao.java
public List<SurgeryRequestBean> getRequests(UserBean userBean) { List<SurgeryRequestBean> requestList = null; try {//from w ww. j a v a 2s.co m session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from RequestBean where createdBy = :user"); query.setEntity("user", userBean); requestList = query.list(); } catch (HibernateException e) { requestList = null; e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return requestList; } }
From source file:com.neu.web.phmis.dao.DoctorDao.java
public List<UserBean> getResourceManagers(EnterpriseBean enterpriseBean, RoleBean roleBean) { List<UserBean> userList = null; try {//from w ww .ja v a 2 s. c om session = HibernateUtil.getSessionFactory().openSession(); Query query = session .createQuery("from UserBean where enterpriseBean = :enterprise and roleBean = :role"); query.setEntity("enterprise", enterpriseBean); query.setEntity("role", roleBean); userList = query.list(); } catch (HibernateException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return userList; } }
From source file:com.neu.web.phmis.dao.DoctorDao.java
public List<SurgeryBean> getSurgeries(UserBean userBean) { List<SurgeryBean> surgeryList = null; try {/*from w ww .jav a 2 s .co m*/ session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from SurgeryBean where doctor = :user and scheduleDate is NOT NULL"); query.setEntity("user", userBean); surgeryList = query.list(); for (SurgeryBean sb : surgeryList) { Hibernate.initialize(sb.getOperatingRoomBean()); } } catch (HibernateException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return surgeryList; } }
From source file:com.neu.web.phmis.dao.InventoryDao.java
public List<DeviceRequestBean> getDeviceRequests(EnterpriseBean enterpriseBean) { List<DeviceRequestBean> deviceRequestList = null; try {// w w w . ja v a 2s.c o m session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from DeviceRequestBean where warehouse = :warehouse"); query.setEntity("warehouse", enterpriseBean); deviceRequestList = query.list(); } catch (HibernateException e) { deviceRequestList = null; e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return deviceRequestList; } }
From source file:com.neu.web.phmis.dao.InventoryDao.java
public List<OrderBean> getOrders(EnterpriseBean enterpriseBean) { List<OrderBean> orderList = null; try {/*from w ww.ja va 2 s . c om*/ session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from OrderBean where orderedBy = :id"); query.setEntity("id", enterpriseBean); orderList = query.list(); } catch (HibernateException e) { session.getTransaction().rollback(); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return orderList; } }
From source file:com.neu.web.phmis.dao.InventoryDao.java
public List<InventoryItemBean> getInventory(EnterpriseBean enterpriseBean) { List<InventoryItemBean> inventoryItemList = null; try {/* ww w . ja v a 2s . c o m*/ session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from InventoryItemBean where enterpriseBean = :bean"); query.setEntity("bean", enterpriseBean); inventoryItemList = query.list(); } catch (HibernateException e) { session.getTransaction().rollback(); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return inventoryItemList; } }
From source file:com.neu.web.phmis.dao.ResourceDao.java
public List<SurgeryRequestBean> getSurgeryRequests(EnterpriseBean enterpriseBean, RoleBean roleBean) { List<SurgeryRequestBean> surgeryRequestList = null; try {//w w w. j av a2 s. c o m session = HibernateUtil.getSessionFactory().openSession(); Query query = session .createQuery("from UserBean where enterpriseBean = :enterpriseBean and roleBean = :roleBean"); query.setEntity("enterpriseBean", enterpriseBean); query.setEntity("roleBean", roleBean); List<UserBean> userList = query.list(); query = session.createQuery("from SurgeryRequestBean where createdBy IN (:list)"); query.setParameterList("list", userList); surgeryRequestList = query.list(); } catch (HibernateException e) { surgeryRequestList = null; e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return surgeryRequestList; } }
From source file:com.neu.web.phmis.dao.ResourceDao.java
public List<DeviceRequestBean> getDeviceRequests(UserBean createdBy) { List<DeviceRequestBean> deviceRequestList = null; try {//from ww w .j a v a 2s . com session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from DeviceRequestBean where createdBy = :user"); query.setEntity("user", createdBy); deviceRequestList = query.list(); } catch (HibernateException e) { deviceRequestList = null; e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return deviceRequestList; } }
From source file:com.neu.web.phmis.dao.ResourceDao.java
public List<UserBean> getInventoryManagers(EnterpriseBean enterpriseBean, RoleBean roleBean) { List<UserBean> userList = null; try {/* w w w . j a v a2s. c o m*/ session = HibernateUtil.getSessionFactory().openSession(); Query query = session .createQuery("from UserBean where enterpriseBean = :enterprise and roleBean = :role"); query.setEntity("enterprise", enterpriseBean); query.setEntity("role", roleBean); userList = query.list(); } catch (HibernateException e) { userList = null; e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return userList; } }
From source file:com.neu.web.phmis.dao.ResourceDao.java
public HashMap<Integer, String> getRoomsMap(EnterpriseBean enterpriseBean) { HashMap<Integer, String> roomsMap = new HashMap<>(); try {// ww w . j a v a2s .com session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from OperatingRoomBean where enterpriseBean = :bean"); query.setEntity("bean", enterpriseBean); List<OperatingRoomBean> roomList = query.list(); for (OperatingRoomBean operatingRoomBean : roomList) { roomsMap.put(operatingRoomBean.getId(), operatingRoomBean.getLocation()); } } catch (HibernateException e) { session.getTransaction().rollback(); surgeryRequestBean = null; e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return roomsMap; } }