Search code examples
javahibernatemany-to-manyone-to-manyhibernate-tools

Hibernate Tools 4.0.0 Detect many-to-many tables NOT working with MySQL Db


I am using Hibernate Tools to reverse engineer from a MySQL 5.5.27 using STS 2.9.2 and Hibernate Tools 4.0.0.

It generates the POJO classes correctly, but is NOT picking up on the foreign key relationships defined across the tables (i.e. no sets nor relationships created at all!).

Any idea from your experience whether this tool works with MySQL or what I am doing wrong?

Thanks,

Bob


Solution

  • OK, I got it work at last!

    The problem was, as with all things of a technical nature both simple and profound.

    In a word: CaseSensitive

    I had created my tables with capitaliZatioN (i.e. Person, Phone) and I used the MySQL Workbench to create the foreign keys and they looked like this:

    CONSTRAINT FK_Phone_Person FOREIGN KEY (person_id) REFERENCES Person (person_id)

    instead of

    CONSTRAINT FK_Phone_Person FOREIGN KEY (person_id) REFERENCES person (person_id)

    Notice the capitalization.

    SOO happy after spending a lot of blood, sweat and tears trying to get that damn thing to work when all along the case was the problem!