Example usage for org.hibernate Query setBoolean

List of usage examples for org.hibernate Query setBoolean

Introduction

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

Prototype

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

Source Link

Document

Bind a named boolean-valued parameter.

Usage

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  w  w .  java2  s .  c om
        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.PatientDaoImpl.java

@SuppressWarnings("unchecked")
@Override//w  ww  . j av a 2s .c o  m
public List<Patient> getAllPatients() {
    return getHibernateTemplate().execute(new HibernateCallback<List<Patient>>() {
        @Override
        public List<Patient> doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery(
                    "from Patient p where p.isDeleted = :deleted order by p.lastModifiedDate DESC");
            query.setBoolean("deleted", false);
            return query.list();
        }
    });
}

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

@Override
public Patient getByCode(final String code) {
    return getHibernateTemplate().execute(new HibernateCallback<Patient>() {
        @Override//from   w ww.j av  a 2  s .  com
        public Patient doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery("from Patient p where p.code = :code and p.isDeleted = :deleted");
            query.setString("code", code);
            query.setBoolean("deleted", false);
            return (Patient) query.uniqueResult();
        }
    });
}

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

@SuppressWarnings("unchecked")
@Override/*from www. j  ava2 s.c o  m*/
public List<Patient> searchPatient(final String patientName, final String patientCode,
        final String patientPhone) {
    return getHibernateTemplate().execute(new HibernateCallback<List<Patient>>() {
        @Override
        public List<Patient> doInHibernate(Session sn) throws HibernateException {
            /// creating Query String
            String queryString = "from Patient p where p.isDeleted = :deleted ";
            /// checker for Input
            if ((!patientName.isEmpty()) && (patientName != null)) {
                queryString += " and (p.fName like :patientName or p.midName like :patientName or p.lName like :patientName ) ";
            } //end if condition
            if ((!patientCode.isEmpty()) && (patientCode != null)) {
                queryString += " and p.code = :patientCode ";
            } //end if condition
            if ((!patientPhone.isEmpty()) && (patientPhone != null)) {
                queryString += " and (p.phoneNumber1 = :patientPhone or p.phoneNumber2 = :patientPhone) ";
            } //end if condition
              // Order Data 
            queryString += " order by p.lastModifiedDate DESC ";

            Query query = sn.createQuery(queryString);
            query.setBoolean("deleted", false);
            if ((!patientName.isEmpty()) && (patientName != null)) {
                query.setString("patientName", '%' + patientName + '%');
            } //end if condition
            if ((!patientCode.isEmpty()) && (patientCode != null)) {
                query.setString("patientCode", patientCode);
            } //end if condition
            if ((!patientPhone.isEmpty()) && (patientPhone != null)) {
                query.setString("patientPhone", patientPhone);
            } //end if condition
              // return result
            return (List<Patient>) query.list();
        }
    });
}

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

@SuppressWarnings("unchecked")
@Override// www. j  a v a2 s  .c  o m
public List<FastPatient> getFastPatientList(final String patientInfo) {
    return getHibernateTemplate().execute(new HibernateCallback<List<FastPatient>>() {
        @Override
        public List<FastPatient> doInHibernate(Session sn) throws HibernateException {
            /// creating Query String
            Query query = sn.createQuery(
                    "select p.id as id , p.fName as fName , p.midName as mName , p.lName as lName , p.code as code "
                            + " , p.phoneNumber1 as phoneNumber from Patient p "
                            + " where p.isDeleted = :deleted and ( p.code like :patientCode or p.fName like :patientFName or p.midName like :PatientMidName "
                            + " or p.lName like :PatientLName or p.phoneNumber1 like :patientPhoneNumber1 or p.phoneNumber2 like :patientPhoneNumber2  "
                            + " ) ");
            query.setString("patientCode", "%" + patientInfo + "%");
            query.setString("patientFName", "%" + patientInfo + "%");
            query.setString("PatientMidName", "%" + patientInfo + "%");
            query.setString("PatientLName", "%" + patientInfo + "%");
            query.setString("patientPhoneNumber1", "%" + patientInfo + "%");
            query.setString("patientPhoneNumber2", "%" + patientInfo + "%");
            query.setBoolean("deleted", false);
            // transform the Returned Results
            List<FastPatient> fastPatientList = query
                    .setResultTransformer(Transformers.aliasToBean(FastPatient.class)).list();
            // return Transformed List
            return fastPatientList;
        }
    });
}

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

@SuppressWarnings("unchecked")
@Override/*from   w  w  w.j  a v a2s .com*/
public List<Patient> searchForPatient(final String patientInfo) {
    return getHibernateTemplate().execute(new HibernateCallback<List<Patient>>() {
        @Override
        public List<Patient> doInHibernate(Session sn) throws HibernateException {
            /// creating Query String
            Query query = sn.createQuery("select p from Patient p "
                    + " where p.isDeleted = :deleted and ( p.code like :patientCode or p.fName like :patientFName or p.midName like :PatientMidName "
                    + " or p.lName like :PatientLName or p.phoneNumber1 like :patientPhoneNumber1 or p.phoneNumber2 like :patientPhoneNumber2  "
                    + " ) order by p.lastModifiedDate DESC ");
            query.setString("patientCode", "%" + patientInfo + "%");
            query.setString("patientFName", "%" + patientInfo + "%");
            query.setString("PatientMidName", "%" + patientInfo + "%");
            query.setString("PatientLName", "%" + patientInfo + "%");
            query.setString("patientPhoneNumber1", "%" + patientInfo + "%");
            query.setString("patientPhoneNumber2", "%" + patientInfo + "%");
            query.setBoolean("deleted", false);
            // return Transformed List
            return (List<Patient>) query.list();
        }
    });
}

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

@SuppressWarnings("unchecked")
@Override//from  www.ja  v  a 2  s. c  om
public List<ReservationWay> getAllReservationWays() {
    return getHibernateTemplate().execute(new HibernateCallback<List<ReservationWay>>() {
        @Override
        public List<ReservationWay> doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery("from ReservationWay where isDeleted=:deleted ");
            query.setBoolean("deleted", false);
            return (List<ReservationWay>) query.list();
        }
    });
}

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

@Override
public ReservationWay getDefaultReservationWay() {
    return getHibernateTemplate().execute(new HibernateCallback<ReservationWay>() {
        @Override/*from  ww w  . java2 s.c  o m*/
        public ReservationWay doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery("from ReservationWay where defaultOne=:default");
            query.setBoolean("default", true);
            return (ReservationWay) query.uniqueResult();
        }
    });
}

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

@SuppressWarnings("unchecked")
@Override//from   w  ww.  j av  a 2s . c  o m
public List<ReservationWay> getReservationWaysWithPattern(final String pattern) {
    return getHibernateTemplate().execute(new HibernateCallback<List<ReservationWay>>() {
        @Override
        public List<ReservationWay> doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery(
                    "from ReservationWay r where r.isDeleted=:deleted AND (r.nameEn LIKE :nameEn OR r.nameAr LIKE :nameAr)");
            query.setBoolean("deleted", false);
            query.setString("nameAr", "%" + pattern + "%");
            query.setString("nameEn", "%" + pattern + "%");
            return (List<ReservationWay>) query.list();
        }
    });
}

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

@SuppressWarnings("unchecked")
@Override/*from   w ww. ja va 2  s .com*/
public List<WeekDay> getWorkingWeekDays() {
    return getHibernateTemplate().execute(new HibernateCallback<List<WeekDay>>() {
        @Override
        public List<WeekDay> doInHibernate(Session sn) throws HibernateException {
            Query query = sn.createQuery("from WeekDay where offLine <> :offLine");
            query.setBoolean("offLine", true);
            return (List<WeekDay>) query.list();
        }
    });
}