@SuppressWarnings("unchecked") @Transactional public List<ClinicModel> getPharmacy(String speciality, String location) { logger.debug("getPharmacy start"); List<ClinicModel> list = new ArrayList<ClinicModel>(); Session session = this.getSession(); List<Clinic> clinics = session .createQuery("from Clinic where type=:paramType") .setParameter("paramType", "pharmacy") .list(); for (Clinic c : clinics) { logger.debug(c.getName() + " " + c.getSpecialities() + " " + c.getAddresses()); boolean specialityMatch = false; if (c.getSpecialities() != null) { for (String spec : c.getSpecialities().split(",")) { logger.debug(spec); if (spec.toLowerCase().equals(speciality.toLowerCase())) { specialityMatch = true; break; } } } logger.debug("Speciality Match : " + specialityMatch); if (!specialityMatch) continue; boolean addressMatch = false; for (ClinicAddress addr : c.getAddresses()) { if (addr.getCity().toLowerCase().equals(location.toLowerCase())) { addressMatch = true; break; } } logger.debug("addressMatch Match : " + addressMatch); if (!addressMatch) continue; ClinicModel model = new ClinicModel(); model.setClinicName(c.getName()); model.setClinicDesc(c.getDescription()); model.setClinicAddress(c.getAddresses().toString()); model.setClinicPhones(c.getPhoneNos().toString()); list.add(model); } logger.debug("getPharmacy end"); return list; }