cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.set(Calendar.AM_PM, Calendar.AM);
Statistic statistic = statisticRepository.find(messageType, careUnit, cal.getTime());
if (statistic == null) {
statistic = new Statistic(messageType, cal.getTime(), careUnit, numberOfMessages);
statisticRepository.store(statistic);
} else {
statistic.setNumber(statistic.getNumber() + numberOfMessages);
statisticRepository.merge(statistic);
}
}