spring-projects / spring-data-jpa

Simplifies the development of creating a JPA-based data access layer.
https://spring.io/projects/spring-data-jpa/
Apache License 2.0
3.03k stars 1.42k forks source link

3.2.5 - Issue with dropping unexisting tables with ddl-auto=create #3483

Closed raullapeira closed 6 months ago

raullapeira commented 6 months ago

Configuration is:

spring.jpa.hibernate.ddl-auto=create

The code setup is a typical 1-to-n relation with standard entities

Exception is

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table tarea drop foreign key FKfu8olm9a6nfviq94l047vpwb0" via JDBC [Table 'curso_spring_boot.tarea' doesn't exist]
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:94) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
    at org.hibernate.tool.schema.internal.Helper.applySqlString(Helper.java:233) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
    at org.hibernate.tool.schema.internal.Helper.applySqlStrings(Helper.java:217) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applyConstraintDropping(SchemaDropperImpl.java:470) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropConstraintsTablesSequences(SchemaDropperImpl.java:242) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
[...]
Caused by: java.sql.SQLSyntaxErrorException: Table 'curso_spring_boot.tarea' doesn't exist
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:763) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648) ~[mysql-connector-java-8.0.28.jar:8.0.28]

I think the call hierarchy goes south around the red square area

issue

christophstrobl commented 6 months ago

Thank you @raullapeira for getting in touch. This is an issue with hibernate that should be reported here.