URL-адрес API не работает, я заметил, что данные заполняются только в БД. Я использую Spring Boot в домашней базе данных H2.
@Component
публичный класс JobCompletionNotificationListener реализует JobExecutionListener {
Код: Выделить всё
private static final Logger log = LoggerFactory.getLogger(JobCompletionNotificationListener.class);
private final EntityManager em;
@Override
@Transactional
public void afterJob(JobExecution jobExecution) {
if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
log.info("!!! JOB FINISHED! Time to verify the results");
Map teamData = new HashMap();
em.createQuery("select m.team1, count(*) from Match m group by m.team1", Object[].class)
.getResultList()
.stream()
.map(e -> new Team((String) e[0], (long) e[1]))
.forEach(team -> teamData.put(team.getTeamName(), team));
em.createQuery("select m.team2, count(*) from Match m group by m.team2", Object[].class)
.getResultList()
.stream()
.forEach(e -> {
Team team = teamData.get((String) e[0]);
team.setTotalMatches(team.getTotalMatches() + (long) e[1]);
});
em.createQuery("select m.matchWinner, count(*) from Match m group by m.matchWinner", Object[].class)
.getResultList()
.stream()
.forEach(e -> {
Team team = teamData.get((String) e[0]);
if (team != null)
team.setTotalWins((long) e[1]);
});
teamData.values().forEach(team -> em.persist(team));
teamData.values().forEach(team -> System.out.println(team));
}
}
Нужна помощь по этому поводу, есть ли что-то, что мне не хватает?
Заранее спасибо!
Подробнее здесь: https://stackoverflow.com/questions/786 ... nsole-upon