I have been using hibernate for quite a while and recently am trying to switch over to annotations and have run into a problem / limitation. The database that I am implementing on top of uses combination keys for it's primary keys. While, I know that hibernate prefers a surrogate approach, I don't have that option.
With combination keys, you often have to map a colum multiple times. For instance, you may have a column like ITEM that maps to one property and then that same ITEM column participlates with some other columns to act as a foreign key to another table. Unfortunately, hibernate does not allow you to have the same column name declared in a mapping multiple times.
In the xml mapping syntax, you get arround this by a formula element that simply has the column name. However, this is not possible in the annotations syntax. While the syntax does support an @JoinColumns annotation that allows you to list out all of the @JoinColumn elements in the key, it will not accept an @Formula annotation in the list. Is there another way to work around this?? Or, is there another annotation that I have missed that is used for this purpose?
Thanx,
LES
|