Spring HibernateJPA弹簧靴

Spring HibernateJPA弹簧靴,spring,hibernate,spring-boot,jpa,Spring,Hibernate,Spring Boot,Jpa,我已经为我的spring boot应用程序创建了所有模型,并根据业务逻辑成功地指定了它们之间的关系。在我的属性文件中,我将hibernate auto ddl选项设置为create,以根据实体之间的关系生成所有表。我还使用liquibase进行数据库迁移 问题是,从日志中,我可以看到hibernate在创建表之前正在修改表,因此抛出运行时异常“table not found”。为什么要在创建表之前更改表?如何解决这个问题 任何帮助都是值得赞赏的。提前谢谢 一些日志例如 Error executi

我已经为我的spring boot应用程序创建了所有模型,并根据业务逻辑成功地指定了它们之间的关系。在我的属性文件中,我将hibernate auto ddl选项设置为create,以根据实体之间的关系生成所有表。我还使用liquibase进行数据库迁移

问题是,从日志中,我可以看到hibernate在创建表之前正在修改表,因此抛出运行时异常“table not found”。为什么要在创建表之前更改表?如何解决这个问题

任何帮助都是值得赞赏的。提前谢谢

一些日志例如

Error executing DDL "alter table application drop foreign key FKrtuepaxepo3o6x0pkn0w62ucg" via JDBC Statement.

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "APPLICATION" not found; SQL statement:
alter table application drop foreign key FKrtuepaxepo3o6x0pkn0w62ucg

.......
.......
.......
Hibernate: drop table if exists application
create table application (id bigint not null auto_increment
alter table application add constraint UK_5jl5nuoh207t0japuutb4avd4 unique (application_name)
为什么在创建“应用程序”之前需要表名为“应用程序”

我在开发中使用H2数据库,在生产中使用MYSQL。但是,在此之前,我在“application-dev.yml”中使用了“org.hibernate.dialogue.mysql5innodbdialogue”方言。将其更改为h2方言(org.hibernate.dialogue.h2dialogue)解决了问题

但是,application-prod.yml中的正确方言应该是什么?我正在生产中使用MYSQL。我现在使用的方言是“org.hibernate.dialogue.mysql5innodbdialogue”。这将进一步在生产中产生问题

application-prod.yml

datasource:
#    type: com.zaxxer.hikari.HikariDataSource
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/appscoredb
    username:
    password:
    hikari:
      poolName: Hikari
      auto-commit: false
#  h2:
#    console:
#        enabled: true
#        settings:
#          web-allow-others: true
  jpa:
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
    hibernate:
      ddl-auto: none

    show-sql: true
    properties:
      hibernate.id.new_generator_mappings: true
      hibernate.connection.provider_disables_autocommit: true
      hibernate.cache.use_second_level_cache: false
      hibernate.cache.use_query_cache: false
      hibernate.generate_statistics: false
  liquibase:
    # Remove 'faker' if you do not want the sample data to be loaded automatically
    contexts: prod, faker
    enabled: false

它是通过使用以下方言解决的:org.hibernate.dialogue.mysql5dialogue


我希望它能在不久的将来帮助别人。

它说找不到表应用程序。您还可以包括您的属性文件吗?另外,请将您的代码片段分为相应的块,不清楚它是仅日志、您的类和日志还是其他内容。@Giorgi Tsiklaur-我已经编辑了这个问题。请看一看。尝试ddl auto:UPDATETHAKS它可以工作。。对于上面的生产方言,ddl auto:update可以工作。现在,它不会在创建表之前更改表。但是,对于ddl auto:create,它是在创建表之前更改表。你能解释一下原因吗?这里的概念是什么?我不推荐使用Hibernate在生产中更改表。最好在生产中坚持“更新”。在较低的环境中,您可以使用create drop和create。
datasource:
#    type: com.zaxxer.hikari.HikariDataSource
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/appscoredb
    username:
    password:
    hikari:
      poolName: Hikari
      auto-commit: false
#  h2:
#    console:
#        enabled: true
#        settings:
#          web-allow-others: true
  jpa:
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
    hibernate:
      ddl-auto: none

    show-sql: true
    properties:
      hibernate.id.new_generator_mappings: true
      hibernate.connection.provider_disables_autocommit: true
      hibernate.cache.use_second_level_cache: false
      hibernate.cache.use_query_cache: false
      hibernate.generate_statistics: false
  liquibase:
    # Remove 'faker' if you do not want the sample data to be loaded automatically
    contexts: prod, faker
    enabled: false