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: Help needed with mapping a Map with entity keys and values
PostPosted: Tue Feb 02, 2010 7:05 pm 
Newbie

Joined: Mon Mar 08, 2004 12:32 pm
Posts: 7
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.


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.