Hibernate:hbm2ddl.auto=update apppens org.hibernate.tool.schema.spi.CommandAcceptanceException:执行DDL“创建索引...”时出错
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论