-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @ManyToMany mapped to joined subclass
PostPosted: Fri Aug 28, 2009 11:11 am 
Regular
Regular

Joined: Sat Nov 19, 2005 2:46 pm
Posts: 69
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.

_________________
Stewart
London, UK


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.