当前位置: 首页 > 知识库问答 >
问题:

Hibernate JPA Spring Boot

陶胤
2023-03-14

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

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)
@Table(name = "application")
    @EqualsAndHashCode(onlyExplicitlyIncluded = true)
    public class Application extends AbstractAuditingEntity implements Serializable {

        private static final long serialVersionUID = 1L;
}

但是,application-prod.yml中合适的方言应该是什么呢?我正在生产中使用MYSQL。我在这里使用的当前方言是“org.hibernate.dialoget.mysql5innodbdialction”。这将进一步造成生产上的问题。

应用程序-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

共有1个答案

宓季同
2023-03-14

它通过使用这个方言来解决:org.hibernate.dialoget.mysql5dialogise

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

 类似资料:

相关问答

相关文章

相关阅读