Hibernate:hbm2ddl.auto=update apppens org.hibernate.tool.schema.spi.CommandAcceptanceException:执行DDL“创建索引...”时出错

发布于 2025-01-10 10:42:42 字数 3798 浏览 0 评论 0原文

Hibernate 5.4.2.Final,MySQL 5.7

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create index idx_taskId_time on timer_task_history (taskId, time)" via JDBC Statement
        at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyIndexes(AbstractSchemaMigrator.java:331) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:84) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
         .....
Caused by: java.sql.SQLSyntaxErrorException: Duplicate key name 'idx_taskId_time'
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:764) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75) ~[c3p0-0.9.5.4.jar:0.9.5.4]
        at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        ... 78 more
[2022-02-28T16:56:45,579][WARN ][o.h.t.s.i.ExceptionHandlerLoggedImpl] [dev1_cs19_collector] GenerationTarget encountered exception accepting command : Error executing DDL "create index idx_type_time on timer_task_history (type, time)" via JDBC Statement

我的应用程序是一个具有3个节点的分布式系统,在执行创建索引警报表时有时会出错;分布式应用程序启动时抛出Duplicate key异常是否正常?如何修复它?

Hibernate 5.4.2.Final,MySQL 5.7

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create index idx_taskId_time on timer_task_history (taskId, time)" via JDBC Statement
        at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyIndexes(AbstractSchemaMigrator.java:331) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:84) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141) [hibernate-core-5.4.2.Final.jar:5.4.2.Final]
         .....
Caused by: java.sql.SQLSyntaxErrorException: Duplicate key name 'idx_taskId_time'
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:764) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648) ~[mysql-connector-java-8.0.18.jar:8.0.18]
        at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75) ~[c3p0-0.9.5.4.jar:0.9.5.4]
        at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
        ... 78 more
[2022-02-28T16:56:45,579][WARN ][o.h.t.s.i.ExceptionHandlerLoggedImpl] [dev1_cs19_collector] GenerationTarget encountered exception accepting command : Error executing DDL "create index idx_type_time on timer_task_history (type, time)" via JDBC Statement

My application is a distributed system which has 3 nodes, it errors the error sometimes when ececute create index or alert table; is it normal throw Duplicate key exception when the distributed application startup? How to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文