详细信息:表 "batch_job_instance" 中不存在键 (job_instance_id)=(72)



已解决

数据库中有两个模式:public和umler。

之后,dba团队为上面的两个模式生成了spring-batch模式。

并且设置了外键:

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".

我可以看到的步骤是:

  1. 按名称查找作业
  2. 如果不存在,将在job_instance中创建一个新记录(id=72(
  3. 在job_execution中插入新记录。在这一步我们会遇到错误

已解决

数据库中有两个模式:public和umler。

之后,dba团队为上面的两个模式生成了spring-batch模式。

并且设置了外键:

umler.job_inst_exec_fk (job_instance_id reference to public.batch_job_instance(job_instance_id) ) =)))

最新更新