public void removeTask(DischargeSummaryJobType jobType) throws ForeignKeyViolationException { DomainFactory factory = getDomainFactory(); ArrayList<String> markers = new ArrayList<String>(); ArrayList<Serializable> values = new ArrayList<Serializable>(); String sql = "from DischargeSummarySchedule as dss where dss.jobType = :id"; markers.add("id"); values.add(getDomLookup(jobType)); List jobs = factory.find(sql.toString(), markers, values); if (jobs.size() > 0) { factory.delete((DischargeSummarySchedule) jobs.get(0)); } }