【发布时间】:2020-11-05 23:01:32
【问题描述】:
已解决
我们在 db 中有 2 个模式:public 和 umler。
之后,dba 团队已经为上面的两个 schema 生成了 spring batch schema。
并且设置了外键:
umler.job_inst_exec_fk (job_instance_id reference to public.batch_job_instance(job_instance_id) ) =)))
----------------问题-------
我在 springboot 中使用 Spring Batch,其中我有一个用于该工作的 postgres 数据源。但是当我运行这项工作时,我遇到了错误:
Detail: Key (job_instance_id)=(72) is not present in table "batch_job_instance".; nested exception is org.postgresql.util.PSQLException: ERROR: insert or update on table "batch_job_execution" violates foreign key constraint "job_inst_exec_fk"
Detail: Key (job_instance_id)=(72) is not present in table "batch_job_instance".] with root cause
org.postgresql.util.PSQLException: ERROR: insert or update on table "batch_job_execution" violates foreign key constraint "job_inst_exec_fk"
Detail: Key (job_instance_id)=(72) is not present in table "batch_job_instance".
我能看到的步骤是:
- 按姓名查找工作
- 如果不存在,将在 job_instance 中创建一个新记录(id = 72)
- 将新记录插入到 job_execution。在这一步我们会遇到错误。
【问题讨论】:
-
如果您已经解决了问题,请将解决方案添加为答案并接受该答案。否则问题将保持为“未解决”
标签: postgresql spring-boot spring-batch