Main contents of error reporting information:
Cant DROP [xxx]; check that column/key exists
Error reporting information reference data:
A configuration as follows:
package org.hibernate.tool.schema.internal;
public abstract class AbstractSchemaMigrator implements SchemaMigrator {
…………
private UniqueConstraintSchemaUpdateStrategy uniqueConstraintStrategy;
}
The reason for the locking problem is that the default configuration is: delete + first and then create.
Then the solution of the problem should consider using the second one: RECREATE_QUIETLY, try to create it directly and ignore the exception.
Problem-solving:
Configure the above mentioned configuration in application.yml, but since this configuration was not prompted, after a query, it was found in.
package org.hibernate.cfg;
public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
……
/*
In most dialects, unique constraints are used for unique columns and unique keys. SchemaUpdate needs to create these constraints, but DB support for finding existing constraints is extremely inconsistent. In addition, non-explicitly named unique constraints use randomly generated characters. Therefore, choose from these strategies. org.hibernate.tool.hbm2ddl.UniqueConstraintSchemaUpdateStrategy.DROP_RECREATE_QUIETLY (default): Attempt to delete and then (re)create each unique constraint. Ignore any exceptions thrown. org.hibernate.tool.hbm2ddl.UniqueConstraintSchemaUpdateStrategy.RECREATE_QUIETLY : Attempts to (re)create the unique constraint, ignoring any exceptions thrown if the constraint already exists org.hibernate.tool. hbm2ddl.UniqueConstraintSchemaUpdateStrategy.SKIP : Don't try to create unique constraint structure updates
*/
String UNIQUE_CONSTRAINT_SCHEMA_UPDATE_STRATEGY = "hibernate.schema_update.unique_constraint_strategy";
……
}
Configurate in application.yml:
spring:
## jpa configuration
jpa:
hibernate:
ddl-auto: ${JPA_HIBERNATE_DDL_AUTO:update}
open-in-view: ${JPA_OPEN_IN_VIEW:true}
show-sql: ${JPA_SHOW_SQL:false}
properties:
hibernate:
schema_update:
## This configuration is the focus of this blog post, after setting, the error report no longer appears
unique_constraint_strategy: RECREATE_QUIETLY
Read More:
- [Solved] ln: failed to create symbolic link ‘/usr/bin/java’: File exists
- [Solved] Error attempting to get column ‘xxxx_time‘ from result set. Cause: java.sql.SQLFeatureNotSupportedEx
- How to Solve Error executing DDL in JPA
- [Solved] IDEA JPA Custome Query Error: Can‘t resolve symbol ‘Type‘
- [Solved] Tomcat Error: org.apache.tomcat.util.digester.Digester.fatalError Parse fatal error at line [40] column [36]
- How to get the current time in java time string
- [Solved] JPA query data error: Page 1 of 0 containing UNKNOWN instances
- JPA multiple-data source startup error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘t
- [Solved] JPA sett in parameter error: Java.lang.illegalargumentexception
- [Solved] Specified key was too long; max key length is 767 bytes
- Hibernate Error: Error executing DDL “create table course (xxx)“
- [Solved] Mybatis Error: attempting to get column ‘XX’ from result set
- Using mybatis statement.getGenreatedKeys(); usegeneratedkeys = “true”; using self incrementing primary key to get primary key value policy and Oracle do not support self incrementing, Oracle uses sequence
- Public Key Retrieval is not allowed [How to Solve]
- [How to Solve]Repeated column in mapping for entity,should be mapped with insert=“false“ update=“false“
- [Solved] Docker Start Error: Error response from daemon: oci runtime error: container with id exists: 7f4336393ab
- [Solved] JavaErrors_mybatis collection column Pass Value Error
- [Solved] Error updating database. Cause: java.sql.SQLException: Incorrect integer value: ‘**‘ for column
- [Solved] mybatis Error querying database. Cause: java.sql.SQLException: The server time zone value
- Springboot integration RabbitMQ times error: Failed to check/redeclare auto-delete queue(s).