Example usage for org.hibernate Query setInteger

List of usage examples for org.hibernate Query setInteger

Introduction

In this page you can find the example usage for org.hibernate Query setInteger.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setInteger(String name, int val) 

Source Link

Document

Bind a named int-valued parameter.

Usage

From source file:com.neu.web.phmis.dao.AdminDao.java

public ArrayList<EnterpriseBean> getEnterpriseList(int typeId) {

    List<EnterpriseBean> enterpriseList = null;

    try {//w  w w . j a  v a  2 s .c  om

        session = HibernateUtil.getSessionFactory().openSession();

        Query query = session.createQuery("from EnterpriseBean where typeId = :typeId");
        query.setInteger("typeId", typeId);
        enterpriseList = query.list();

    } catch (HibernateException e) {
        session.getTransaction().rollback();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return (ArrayList<EnterpriseBean>) enterpriseList;
    }

}

From source file:com.neu.web.phmis.dao.DoctorDao.java

public ProductBean getProduct(int productId) {

    ProductBean productBean = null;/*from w  w  w  . j  av a  2 s .  c  o  m*/

    try {

        session = HibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery("from ProductBean where id = :id");
        query.setInteger("id", productId);

        productBean = (ProductBean) query.uniqueResult();

    } catch (HibernateException e) {
        productBean = null;
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return productBean;
    }

}

From source file:com.neu.web.phmis.dao.DoctorDao.java

public SurgeryRequestBean getRequestDetails(int requestId) {

    try {/*from   w  ww.  ja va2  s .  c o m*/

        session = HibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery("from SurgeryRequestBean where id = :id");
        query.setInteger("id", requestId);
        surgeryRequestBean = (SurgeryRequestBean) query.uniqueResult();
        Hibernate.initialize(surgeryRequestBean.getRequestedProducts());
        Hibernate.initialize(surgeryRequestBean.getProcessedBy());

    } catch (HibernateException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return surgeryRequestBean;
    }

}

From source file:com.neu.web.phmis.dao.ProductDao.java

public List<ProductBean> getProducts(int enterpriseId) {

    List<ProductBean> productList = null;

    try {/*  ww  w.j  a v  a2  s.c  om*/

        session = HibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery("from ProductBean where enterpriseId = :id");
        query.setInteger("id", enterpriseId);

        productList = query.list();

    } catch (HibernateException e) {
        productList = null;
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return productList;
    }

}

From source file:com.neu.web.phmis.dao.ResourceDao.java

public List<OperatingRoomBean> getOperatingRooms(int enterpriseId) {

    List<OperatingRoomBean> roomList = null;

    try {//  w ww  . j  a  v  a2 s .c  om

        session = HibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery("from OperatingRoomBean where enterpriseId = :id");
        query.setInteger("id", enterpriseId);

        roomList = query.list();

    } catch (HibernateException e) {
        roomList = null;
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return roomList;
    }

}

From source file:com.neu.web.phmis.dao.ResourceDao.java

public List<MedicalStaffBean> getMedicalStaff(int enterpriseId) {

    List<MedicalStaffBean> staffList = null;

    try {//  w w  w . j a  va 2s  . c o  m

        session = HibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery("from MedicalStaffBean where enterpriseId = :id");
        query.setInteger("id", enterpriseId);

        staffList = query.list();

    } catch (HibernateException e) {
        staffList = null;
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return staffList;
    }

}

From source file:com.neu.web.phmis.dao.ResourceDao.java

public SurgeryRequestBean getSurgeryRequestDetails(int requestId) {

    try {/*from w  w  w .ja v  a2  s. co  m*/

        session = HibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery("from SurgeryRequestBean where id = :id");
        query.setInteger("id", requestId);
        surgeryRequestBean = (SurgeryRequestBean) query.uniqueResult();
        Hibernate.initialize(surgeryRequestBean.getRequestedProducts());
        Hibernate.initialize(surgeryRequestBean.getCreatedBy());
        Hibernate.initialize(surgeryRequestBean.getProcessedBy());

    } catch (HibernateException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return surgeryRequestBean;
    }

}

From source file:com.neu.web.phmis.dao.ResourceDao.java

public List<EnterpriseBean> getWarehouses() {

    List<EnterpriseBean> warehouseList = null;

    try {/*from   w  w  w.j  a v a2s .  co  m*/

        session = HibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery("from EnterpriseBean where typeId = :typeId");
        query.setInteger("typeId", CommonUtil.getMapKey(Constants.ENTERPRISE_TYPE, EnterpriseBean.WAREHOUSE));

        warehouseList = query.list();

    } catch (HibernateException e) {
        warehouseList = null;
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
        return warehouseList;
    }

}

From source file:com.ocare.obook.dao.impl.InsuranceProfileDaoImpl.java

@Override
public InsuranceProfile getProfileForCompanyAndExamine(final Integer insurranceCompanyId,
        final Integer examineTypeId) {
    return getHibernateTemplate().execute(new HibernateCallback<InsuranceProfile>() {
        @Override/*w ww .  j av  a2 s . c o  m*/
        public InsuranceProfile doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery(
                    "select p from InsuranceProfile p inner join p.insurranceCompany c inner join p.examineType e where c.id = :insurranceCompanyId and e.id = :examineTypeId and c.isDeleted = :deleted");
            query.setInteger("insurranceCompanyId", insurranceCompanyId);
            query.setInteger("examineTypeId", examineTypeId);
            query.setBoolean("deleted", false);
            return (InsuranceProfile) query.uniqueResult();
        }
    });
}

From source file:com.ocare.obook.dao.impl.ReservationDaoImpl.java

@Override
public List<Reservation> getReservationsForShift(final Date day, final Integer shift) {
    return getHibernateTemplate().execute(new HibernateCallback<List<Reservation>>() {
        @Override//from   www  .j  av a 2 s  .  c o  m
        public List<Reservation> doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery(
                    "select r from Reservation r inner join r.workingTime wt where r.reservationDate = :day and wt.id= :shift and r.status= :status order by attendenceTimeTo asc");
            query.setDate("day", day);
            query.setString("status", "WAITING");
            query.setInteger("shift", shift);
            return (List<Reservation>) query.list();
        }
    });
}