Fixed
Details
Assignee
Vlad MihalceaVlad MihalceaReporter
Nayden GochevNayden GochevLabels
Components
Fix versions
Affects versions
Priority
Major
Details
Details
Assignee
Vlad Mihalcea
Vlad MihalceaReporter
Nayden Gochev
Nayden GochevLabels
Components
Fix versions
Affects versions
Priority
Created July 30, 2014 at 12:44 PM
Updated May 5, 2022 at 11:09 AM
Resolved March 14, 2016 at 2:48 PM
Hibernate DDL is generating wrong FK constraints when we have MappedSupperclass containing ManyToMany relation and if we have more then 2 classes extending it.(doesn't work for 2,3,4 .. works for 1 or the first extending entity only )
I have a MappedSupperclass
And I have several classes that extend this class which are Entities ( more then 1 )
All of them look like (you must have more then 1 ! ) :
The problem is the SQL DDL script that is generated by org.hibernate.cfg.Configuration#generateSchemaCreationScript is using the same FK name for each entity after the second one.
So the generated SQL script looks like this :
As you can notice.. the first one (the abstract one is ok).. the second one is also ok.. but each other entity that extends the mapped super class have the same constraint name which is invalid.
I've tried to debug the problem and saw that it in generateSchemaCreationScript method in org.hibernate.Configuation class contains the following snippet :
org.hibernate.Configuration.java
And here this "fk" ... fk.getName() is the same for each FK... while it should be different because fk.getName() is used inside sqlCreateString method to generate the actual SQL. I believe something is wrong when TableMappings are created.