// 1. create a new study:
String newName = testName + " test " + Math.random();
StudyStatus inprogress = getStudyStatusHome().findStatusInProgress();
Citation c = new ArticleCitation();
c.setTitle(newName);
Analysis a1 = new Analysis();
a1.setName("1 " + newName);
Analysis a2 = new Analysis();
a2.setName("2 " + newName);
Study s = new Study();
s.setName(newName);
s.setStudyStatus(inprogress);
s.setCitation(c);
c.setStudy(s);
s.addAnalysis(a1);
s.addAnalysis(a2);
TaxonLabel label = new TaxonLabel();
label.setTaxonLabel(newName);
label.setStudy(s);
getStudyHome().store(label);
getStudyHome().store(s);
// force commit immeidately, important:
setComplete();
endTransaction();
onSetUp();
// Notes: this is important: why?? there are two copies of s in the same session.
// how???
s = (Study) hibernateTemplate.merge(s);
Long studyID = s.getId();
Long citationID = c.getId();
logger.info("study created: " + s.getName() + "id = " + studyID);
logger.info("citation created: " + c.getTitle() + "id = " + citationID);
logger.info("analysis created: " + a1.getName() + "id = " + a1.getId());
logger.info("analysis created: " + a2.getName() + "id = " + a2.getId());
logger.info("taxonLabel created: " + label.getTaxonLabel() + "id = " + label.getId());
// 2. verify