session = GlobalSessionFactory.get().openSession();
List iterations = session.find("from i in " + Iteration.class +
" where i.endDate >= ?", new Date(), Hibernate.DATE);
Date now = new Date();
for (int i = 0; i < iterations.size(); i++) {
Iteration iteration = (Iteration)iterations.get(i);
DataSample estimatedHoursSample = new DataSample(now, iteration.getId(),
"estimatedHours", iteration.getEstimatedHours());
session.save(estimatedHoursSample);
DataSample actualHoursSample = new DataSample(now, iteration.getId(),
"actualHours", iteration.getActualHours());
session.save(actualHoursSample);
DataSample remainingHoursSample = new DataSample(now, iteration.getId(),
"remainingHours", iteration.getRemainingHours());
session.save(remainingHoursSample);
}
log.info("committing data sample changes");
session.flush();
session.connection().commit();