Reputation: 149
This is driving me crazy -- I'm pretty sure that Hibernate can determine mapping relationships between tables and thus reflect this in the POJO's generated.
Except it's not.
I am using MySQL with STS & Hibernate Tools 4.0.0 and I have a one-to-many and a one-to-one table relationship, between Person <--> Phone and Phone <--> PhoneType and I am able to generate using the 'Hibernate Code Generation Configuration' the 'Domain Code' and the 'DAO Code', however neither of the files have any mappings between the tables.
Now here is a possible issue:
In order to get any annotations at all, I have switched on the option 'Generate EJB3 annotations'. Now I am using plain old Hibernate here, and not JPA.
So my questions are:
Thanks a lot for your help,
Bob
Upvotes: 2
Views: 1538
Reputation: 807
Worked:
I created new reverse engineering XML "hibernateII.reveng.xml" from Hibernate tool plugin in STS eclipse, and it resolved the problem.
Though i had also tried changing content of existing file, but that did not work out and content of old and new files were same, weird, but new file solved the issue.
Upvotes: 0
Reputation: 149
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!
Upvotes: 3