【问题标题】:Detail: Key (job_instance_id)=(72) is not present in table "batch_job_instance"详细信息:表“batch_job_instance”中不存在键 (job_instance_id)=(72)
【发布时间】: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".

我能看到的步骤是:

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

【问题讨论】:

  • 如果您已经解决了问题,请将解决方案添加为答案并接受该答案。否则问题将保持为“未解决”

标签: postgresql spring-boot spring-batch


【解决方案1】:

已解决

我们在 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) ) =)))

【讨论】:

    猜你喜欢
    • 2016-10-20
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多