I feel like I'm 90% there, but I'm stuck on an error and I don't know how to placate Hibernate.
I have three entities, Idea, Category, and Category Group. Ideas can belong to one category for each category group, which I've modelled in my domain model as:
class Idea
{
private Map<CategoryGroup,Category> categories;
}
The mapping in Idea.hbm.xml:
Code:
<map name="categories" table="IDEA_CATEGORIZATION">
<key column="IDEA_ID"/>
<map-key-many-to-many class="my.CategoryGroup">
<column name="IDEA_ID"/>
<column name="CATEGORY_GROUP_ID"/>
</map-key-many-to-many>
<many-to-many column="CATEGORY_ID" class="my.Category"/>
</map>
Hibernate is chucking this exception:
org.hibernate.MappingException: Foreign key (FK4B1745C26C4032C3:CATEGORIES [CATEGORY_GROUP_ID])) must have same number of columns as the referenced primary key (IDEA_CATEGORIZATION [IDEA_ID,CATEGORY_GROUP_ID])
I've added two columns to my <map-key-many-to-many> tag.. but I can't figure out where this FK is coming from. Any guidance would be greatly appreciated.