2 Replies Latest reply on Aug 14, 2017 7:59 AM by Tomas Gustavsson

    WildFly 10.1 Hibernate SchemaManagementException

    valsaraj viswanathan Master

      Hi,

       

      I got following exception in Linux server running with WildFly 10.1 & PostgreSQL:

      javax.persistence.PersistenceException: [PersistenceUnit: em] Unable to build Hibernate SessionFactory

      [Server:app-node-00] at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:179)

      ...

      [Server:app-node-00] Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target

      [alter table app.USER add constraint FKbd6bn1ivwqkoq88eaarhvwr0o foreign key (parent_id) references app.USER]

      [Server:app-node-00] at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59)

      [Server:app-node-00] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431)

      Any solution for this?

       

      Thanks!

        • 1. Re: WildFly 10.1 Hibernate SchemaManagementException
          valsaraj viswanathan Master

          Upgraded to hibernate 5.1.5 but still getting this:

          2017-04-19 18:10:30,113 WARN  [org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl] (ServerService Thread Pool -- 86) GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement

          ...

          Caused by: org.postgresql.util.PSQLException: ERROR: insert or update on table "author_info" violates foreign key constraint "fk8dmiogojwntxbw5acljojkvan"

            Detail: Key (author_id)=(5967) is not present in table "author".

          • 2. Re: WildFly 10.1 Hibernate SchemaManagementException
            Tomas Gustavsson Newbie

            I have the same issue, when upgrading from WildFly 9 to WildFly 10.1, using Oracle database. Seems the keys for foreign constraints changed so we get an exception because Hibernate want's to re-create the foreign key constraint.

             

            Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table AccessRulesData add constraint FKdaev24clq6yofynpsh4kuojno foreign key (AdminGroupData_accessRules) references AdminGroupData]

            <snip>

            Caused by: java.sql.SQLSyntaxErrorException: ORA-02275: such a referential constraint already exists in the table