Dear Forum,
Using Hibernate annotations, how should I declare the mapping for a many-to-many, where the join table is involved in a joined-subclass heirarchy?
For Example:
Two basic entities: Person and Product
A thrid entity: abstract Favourite, which can be a FavouritePerson or a FavouriteProduct. I am mapping this as a joined-subclass.
A Person can have favourite.
A person can be a favourite.
A product can be a favourite.
A product
cannot have a favourite.
How do I map:
Code:
List<Person> person.getFavouritePersons();
List<Product> person.getFavouriteProducts();
List<Person> product.getFans();
List<Person> person.getFans();
On the FAVOURITE table, I have OWNER_ID which FK's to a Person.
On the FAVOURITE_PERSON subclass table I have ENTITY_ID which FK's to a Person.
On the FAVOURITE_PRODUCT subclass table I have ENTITY_ID which FK's to a Product.
(FAVOURITE_PERSON and FAVOURITE_PRODUCT are joined with FAVOURITE by FAVOURITE_ID.)
Hoping you can help.
Regards,
P.S. I had accidentally posted this to the NHibernate fourm. Apologies.