JuyeoungJun / cron-monitoring

for cron-monitoring
0 stars 0 forks source link

CronJob POST 에러 및 CronProcess API 호출 실패 #79

Closed JuyeoungJun closed 3 years ago

JuyeoungJun commented 3 years ago

In GitLab by @gm2202981 on Jul 19, 2021, 14:28

개요

CronJob 생성 실패 및 CronProcess 생성 API 호출 실패 (Unauthorized)

버그 내용

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist: gabia.cronMonitoring.entity.CronJob; nested exception is org.hibernate.PersistentObjectException: detached entity passed to persist: gabia.cronMonitoring.entity.CronJob] with root cause

버그 재현 코드

@Override
    public CronJob save(CronJob cronjob) {
        em.persist(cronjob);
        return em.find(CronJob.class,cronjob.getId());
    }

해결 방안

@Override
    public CronJob save(CronJob cronjob) {
        if (cronjob.getId() == null) {
            em.persist(cronjob);
            return cronjob;
        }
        else {
            return em.merge(cronjob);
        }
    }
JuyeoungJun commented 3 years ago

In GitLab by @gm2202981 on Jul 19, 2021, 15:07

mentioned in merge request !59

JuyeoungJun commented 3 years ago

In GitLab by @gm2202981 on Jul 19, 2021, 16:42

mentioned in merge request !60