Example usage for org.hibernate.query Query setInteger

List of usage examples for org.hibernate.query Query setInteger

Introduction

In this page you can find the example usage for org.hibernate.query 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.testing.pe.dao.ApprovalDAO.java

public List<AccessRequest> getAllApprovedRequest(Long profileId) {
    Session session = this.sessionFactory.openSession();
    Query createQuery = session
            .createQuery("from AccessRequest a where a.requester.id=:userId and a.approvalStatus=:status");
    createQuery.setLong("userId", profileId);
    createQuery.setInteger("status", ApprovalStatus.APPROVED.ordinal());
    List list = createQuery.list();
    session.close();/*from w  w w.j av a 2 s .c  o m*/
    return list;
}

From source file:com.testing.pe.dao.ApprovalDAO.java

public List<AccessRequest> getAllPendingRequest(Long patientId) {
    Session session = this.sessionFactory.openSession();
    Query createQuery = session.createQuery(
            "from AccessRequest a where a.prescription.patient.id=:userId and a.approvalStatus=:status");
    createQuery.setLong("userId", patientId);
    createQuery.setInteger("status", ApprovalStatus.PENDING.ordinal());
    List list = createQuery.list();
    session.close();//from  w w  w  .  jav  a2 s  .  c  o  m
    return list;
}

From source file:DAO.FixingDAO.java

@Override
public List<Fixing> findFixingByYear(Integer year) {

    session = HibernateUtil.getSessionFactory().getCurrentSession();
    transaction = session.getTransaction();

    String hql = "FROM Fixing WHERE  YEAR (fixingDate) = :year ";
    Query query = session.createQuery(hql);
    query.setInteger("year", year);

    List<Fixing> fixings = query.getResultList();

    session.close();// w  ww . j a va2s.  com

    return fixings;

}