hibernate composite key

btocakci used Ask the Experts™
I have a mature project which is using Hibernate as JPA provider. All queries are HQL queries.
Now the requirement is changed for using a composite key on a table that I use frequently. For this, I think I need to use an embedded primary key class thus change all my queries. Can you give me some ideas for coping with this issue with as few modifications as possible?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
no need to change in HQL query change in hbm file its enough .


But this table is associated with much of the tables as 1-to-many and many-to-many. So I need to change all associations and HQLs I think. How to prevent this?
No need HBM file will automatically take care of all relation ship
In general Hibernate discourages the use of composite key as the only unique key, either because of the performance issue (a generated primary key by Hibernate is much more fast), and more reliable (no one can tell your design of these composite key will change later). It is not suggested to over-normalize the database schema.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial