Source:
<code>public long saveRun(Run run) throws IOException { if (runStore != null) { if (run.getId() == AbstractRun.UNSAVED_ID) { run.setName(generateTemporaryName()); run.setId(runStore.save(run)); try { String name = namingScheme.generateNameFor(run); run.setName(name); validateNameOrThrow(run, namingScheme); return runStore.save(run); } catch (MisoNamingException e) { throw new IOException("Cannot save Run - issue with generating name"); } } else { Run managed = getRunById(run.getId()); log.info("update run: " + managed); managed.setAlias(run.getAlias()); managed.setDescription(run.getDescription()); managed.setPairedEnd(run.getPairedEnd()); managed.setCycles(run.getCycles()); managed.setFilePath(run.getFilePath()); <START> Status targetStatus = getStatusById(run.getStatus().getId()); <END> targetStatus.setHealth(run.getStatus().getHealth()); targetStatus.setStartDate(run.getStatus().getStartDate()); targetStatus.setCompletionDate(run.getStatus().getCompletionDate()); targetStatus.setRunName(run.getAlias()); managed.setStatus(targetStatus); for (RunQC runQc : run.getRunQCs()) { if (!managed.getRunQCs().contains(runQc)) { try { managed.addQc(runQc); } catch (MalformedRunQcException e) { log.error("malformed runQC: ", e); } } } managed.setNotes(run.getNotes()); managed.setSequencingParameters(run.getSequencingParameters()); runStore.save(managed); return run.getId(); } } else { throw new IOException("No runStore available. Check that it has been declared in the Spring config."); } }</code><technical_language>need retrieve this separately. managed.getStatus() annotation AbstractRun.status needs JoinColumn. marked ManyToOne Hibernate optimize queries. *should* OneToOne, is schema is currently defined</technical_language>

Target:
public long saveRun(Run run) throws IOException { if (runStore != null) { if (run.getId() == AbstractRun.UNSAVED_ID) { run.setName(generateTemporaryName()); run.setId(runStore.save(run)); try { String name = namingScheme.generateNameFor(run); run.setName(name); validateNameOrThrow(run, namingScheme); return runStore.save(run); } catch (MisoNamingException e) { throw new IOException("Cannot save Run - issue with generating name"); } } else { Run managed = getRunById(run.getId()); log.info("update run: " + managed); managed.setAlias(run.getAlias()); managed.setDescription(run.getDescription()); managed.setPairedEnd(run.getPairedEnd()); managed.setCycles(run.getCycles()); managed.setFilePath(run.getFilePath()); managed.getStatus().setHealth(run.getStatus().getHealth()); managed.getStatus().setStartDate(run.getStatus().getStartDate()); managed.getStatus().setCompletionDate(run.getStatus().getCompletionDate()); managed.getStatus().setInstrumentName(run.getStatus().getInstrumentName()); managed.getStatus().setRunName(run.getStatus().getRunName()); managed.getStatus().setXml(run.getStatus().getXml()); for (RunQC runQc : run.getRunQCs()) { if (!managed.getRunQCs().contains(runQc)) { try { managed.addQc(runQc); } catch (MalformedRunQcException e) { log.error("malformed runQC: ", e); } } } managed.setNotes(run.getNotes()); managed.setSequencingParameters(run.getSequencingParameters()); runStore.save(managed); return run.getId(); } } else { throw new IOException("No runStore available. Check that it has been declared in the Spring config."); } }