I was trying to generate hibernate code through hibernate tools but I was getting issue with association table being created as entity and another id entity was created, and many-to-many relationship was not recognized.
Most of the places, it is written that for many-to-many relationship, association table must have just two foreign keys and no other field. But they forget to mention that these two fields but be the composite primary key of that table.
By setting the foreign keys as composite primary key, hibernate successfully recognized it as many-to-many table along with neither entity of association table is created nor id entity was created. It works like a charm.
Most of the places, it is written that for many-to-many relationship, association table must have just two foreign keys and no other field. But they forget to mention that these two fields but be the composite primary key of that table.
By setting the foreign keys as composite primary key, hibernate successfully recognized it as many-to-many table along with neither entity of association table is created nor id entity was created. It works like a charm.
No comments:
Post a Comment