Issue
I have two proyects with connections to a MariaDB database. Both projects use hibernate as ORM tool and the model objects are declared identical in both projects.
When I deploy both of them at several tables duplicate foreign keys appear (duplicate regarding the relationship, but with different names).
At this very moment the only difference that I see is the hibernate dialect being declared different on each project because of library compatibilities.
Solution
The answer is not clair because the project may change but as it is at versions used on 2022.
As I'm answering my own question I have more info to check so this is interesting:
Sometimes the DBMS (database management system) is set up to alter the naming of the tables to prevent some misstyping like 'do lowercase to the table names provided' with the intention to avoid table proliferation because of wrong naming.
But, as for it's hibernate who is hashing the Foreign key (FK) names (if you don't provide them explicitly) and not the DBMS if you provide different case for the same table names on both projects mapping to the same database, the 2 instances of hibernate will look for 2 different FK names.
Answered By - Antonio E.
Answer Checked By - Gilberto Lyons (JavaFixing Admin)