使用 Jhipster 从 jdl 文件生成应用程序后,在应用程序启动时出现以下错误。当我在与用户表的 OneToOne 关系上使用 jpaDerivedIdentifier 时,我才遇到这个问题。
liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20201128181606_added_entity_constraints_RegistrationOrder.xml::20201128181606-2::jhipster:
Reason: liquibase.exception.DatabaseException: Referential integrity constraint violation: "FK_REGISTRATION_ORDER_STUDENT_ID: PUBLIC.REGISTRATION_ORDER FOREIGN KEY(STUDENT_ID) REFERENCES PUBLIC.STUDENT(ID)"; SQL statement:
ALTER TABLE PUBLIC.registration_order ADD CONSTRAINT fk_registration_order_student_id FOREIGN KEY (student_id) REFERENCES PUBLIC.student (id) [23506-200] [Failed SQL: (23506) ALTER TABLE PUBLIC.registration_order ADD CONSTRAINT fk_registration_order_student_id FOREIGN KEY (student_id) REFERENCES PUBLIC.student (id)]
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:646)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:83)
at liquibase.Liquibase.update(Liquibase.java:202)
at liquibase.Liquibase.update(Liquibase.java:179)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:366)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:314)
at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:93)
at io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:78)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
我的 JDL 是:
entity Student {
birthDate LocalDate
nickName String maxlength(50)
}
entity RegistrationOrder{
paymentAmount BigDecimal required min(0)
materialFee BigDecimal required min(0)
placedDate Instant required
}
relationship OneToOne {
Student{user(login) required} to User with jpaDerivedIdentifier
}
relationship ManyToOne {
RegistrationOrder{student required} to Student
}
如果我删除了“with jpaDerivedIdentifier”,Jhipster 应用程序启动时没有错误。任何的想法?