private ClinicTest findClinicTestByNameForClinic(Session session, Clinic clinic, String testName) throws Exception { ClinicTest test = null; for (ClinicTest t : clinic.getTests()) { if (t.getTest_name().equals(testName)) { test = t; break; } } if (test == null) { logger.debug("Not Found : " + testName); throw new Exception("Not Found : " + testName); } return test; }
@SuppressWarnings("unchecked") @Transactional public void AddTestToClinic(String clinicname, ClinicTest t) { logger.debug("AddTestToClinic start " + clinicname); Clinic c = null; Session session = this.getSession(); List<Clinic> list = session .createQuery("from Clinic where name=:clinicname") .setParameter("clinicname", clinicname) .list(); if (list.size() > 0) { logger.debug("Clinic List > 0 "); c = list.get(0); logger.debug("Clinic found : " + c.getName()); c.getTests().add(t); t.setClinic(c); session.saveOrUpdate(c); } logger.debug("AddTestToClinic end "); }