org.hibernate.tool.schema.spi.CommandAcceptanceException: Unable to execute command [ alter table OrderItem add constraint FK1d77ns82kvwa2hwab9k7xcaog foreign key (order_id) references Order (order_id)]

  1. 0

    Schema Exception Hibernate One to Many

    Stack Overflow | 5 months ago | Hadrian Blackwater
    org.hibernate.tool.schema.spi.CommandAcceptanceException: Unable to execute command [ alter table OrderItem add constraint FK1d77ns82kvwa2hwab9k7xcaog foreign key (order_id) references Order (order_id)]
  2. 0

    MySQL error: Specified key was too long; max key length is 767 bytes

    GitHub | 2 months ago | vrozkovec
    org.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL: CREATE TABLE jv_commit_property ( property_name VARCHAR(200), property_value VARCHAR(200), commit_fk BIGINT, CONSTRAINT jv_commit_property_pk PRIMARY KEY(commit_fk, property_name), CONSTRAINT jv_commit_property_commit_fk FOREIGN KEY(commit_fk) REFERENCES jv_commit(commit_pk) ) ENGINE = InnoDB
  3. 0

    MySQL version - 5.7.15 Hibernate version - hibernate-core | 5.2.3.Final Implementation - JPA 2.1 +persistence.xml file+ {code:xml} <persistence-unit name="defaultPU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <non-jta-data-source>DefaultDS</non-jta-data-source> <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode> <properties> <!--Hibernate properties--> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> <property name="hibernate.id.new_generator_mappings" value="false"/> <property name="hibernate.connection.CharSet" value="UTF-8"/> <property name="hibernate.connection.characterEncoding" value="utf8"/> <property name="hibernate.connection.useUnicode" value="true"/> </properties> </persistence-unit> {code} {code:java} @Entity @Table(name = "CUSTOMER") public class Customer { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "CUSTOMER_ACCOUNT_NUMBER") public Long customerAccountNumber; @Basic @Column(name = "CUSTOMER_ID", unique = true) public String customerId; @Basic @Column(name = "BILLING_ADDRESS") public String billingAddress; public Customer() {} } {code} During startup it generates following error in the logs {noformat} alter table CUSTOMER drop constraint UK_8eumjccoobf7t6psn9exu4gnh Hibernate: alter table CUSTOMER add constraint UK_8eumjccoobf7t6psn9exu4gnh unique (CUSTOMER_ID) [error] o.j.StatementLogger - java.sql.Statement.execute: alter table CUSTOMER drop constraint UK_8eumjccoobf7t6psn9exu4gnh; throws exception: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint UK_8eumjccoobf7t6psn9exu4gnh' at line 2 java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint UK_8eumjccoobf7t6psn9exu4gnh' at line 2 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:536) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115) at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983) at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1936) at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:891) at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:795) at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) [info] o.j.StatementLogger - java.sql.Statement.execute: alter table CUSTOMER add constraint UK_8eumjccoobf7t6psn9exu4gnh unique (CUSTOMER_ID); {noformat}

    Hibernate JIRA | 2 months ago | Binoy Shah
    java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint UK_8eumjccoobf7t6psn9exu4gnh' at line 2
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    jOOQ MySQL how to determine if complex DELETE affected row(s)

    Stack Overflow | 11 hours ago | charneykaye
    org.jooq.exception.DataAccessException: SQL [DELETE FROM `account` WHERE `account`.`id`=14 AND NOT EXISTS (SELECT `id` FROM `account_foo` WHERE `account_foo`.`account_id`=14) AND NOT EXISTS (SELECT `id` FROM `account_bar` WHERE `account_bar`.`account_id`=14); SELECT ROW_COUNT();]; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT ROW_COUNT()' at line 1

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.sql.SQLSyntaxErrorException

      You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Order (order_id)' at line 4

      at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException()
    2. com.mysql.cj
      StatementImpl.execute
      1. com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:686)
      2. com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:663)
      3. com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:653)
      4. com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
      5. com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2041)
      6. com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1994)
      7. com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:890)
      8. com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:788)
      8 frames
    3. org.hibernate.tool
      SchemaManagementToolCoordinator.process
      1. org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:51)
      2. org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:573)
      3. org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:557)
      4. org.hibernate.tool.schema.internal.SchemaMigratorImpl.applyForeignKeys(SchemaMigratorImpl.java:516)
      5. org.hibernate.tool.schema.internal.SchemaMigratorImpl.performMigration(SchemaMigratorImpl.java:315)
      6. org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:137)
      7. org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:110)
      8. org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:176)
      9. org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:65)
      9 frames
    4. Hibernate
      SessionFactoryImpl.<init>
      1. org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:308)
      1 frame
    5. org.hibernate.boot
      SessionFactoryBuilderImpl.build
      1. org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:483)
      1 frame
    6. Hibernate
      Configuration.buildSessionFactory
      1. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:707)
      2. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:723)
      2 frames
    7. one_to_many
      Runner.main
      1. one_to_many.Runner.main(Runner.java:15)
      1 frame