Foreign key name generation broken in Oracle

Description

So I spent about a week investigating this bug and I am finally completely lost, so I hope someone more competent will know what to do about this. Here is the scenario:

I am running Arquillian test which starts Wildfly and deploys an application which uses Infinispan configured to persist data using Hibernate/JPA. The "hibernate.hbm2ddl.auto" is set to "update", so between each test Hibernate will try to update DB schema. The first pass, on an empty database will go without problems, however the second pass will crash.

The issue seems to be that one of the persisted objects contains a Set<String> variable for which Hibernate creates a separate table, and the joins it to the main object table. It will attempt to generate a name for the Foreign key, which is an 30-character MD5 hash from concatenation of table a column names, however for some reason the hash comes out different each time, therefore failing the check on whether the FK exists and Hibernate attempts to create a new FK on the same columns, which Oracle does not allow.

The issue seems to be contained only to Oracle DBs (11g and 12c AFAIK), it does not manifest itself on other BDs we are testing (versions of MsSQL, MySQL, Postgre, DB2 etc.).

Stack trace (cut down, whole is attached):
[java] Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table Person_nickNames add constraint FKsixi37kg6a1032wemki7qf6f3 foreign key (Person_id) references Person]
[java] at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59)
[java] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431)
[java] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:420)
[java] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applyForeignKeys(SchemaMigratorImpl.java:386)
[java] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:214)
[java] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:60)
[java] at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:134)
[java] at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101)
[java] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:472)
[java] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
[java] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
[java] at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
[java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)

...

[java] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[java] Caused by: java.sql.SQLSyntaxErrorException: ORA-02275: such a referential constraint already exists in the table
[java] at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
[java] at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)

Sadly I am not able to provide reproducer for this issue

Attachments

1

Activity

Show:

Christian Beikov April 8, 2022 at 1:06 PM

Since no test case was provided for years, I'll close this issue as out of date. I also believe it will most probably not be an issue any more in 6.0.
If this still is an issue for you, please create a new issue with a test case that reproduces the problem.

Andrea Boriero October 27, 2017 at 8:38 AM

,
a minimal running test would be great, you can use https://github.com/hibernate/hibernate-test-case-templates , it provides a series of templates to simplify hibernate test creation.

Thanks

Former user October 27, 2017 at 6:01 AM
Edited

Sadly no, I have this running only on internal architecture I am unable to give external access to. I might be able to create it eventually but there is no telling when.

Andrea Boriero October 26, 2017 at 8:07 PM

can u please provide failing a test case?

Former user October 26, 2017 at 7:57 PM

, just wanted to make sure you saw the response from ...

Out of Date

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created October 24, 2017 at 8:35 AM
Updated April 8, 2022 at 1:06 PM
Resolved April 8, 2022 at 1:06 PM