Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Hibernate] Mapping a Map question

 
Ruben Matthews
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a Company entity which has a Map property called "companyValues".

private Map<Competence, Integer> companyValues;

The companyValues property uses a Competence entity as its key. Competence is another mapped entity in the system.

Could you explain how I would create this mapping in the Company mapping?

This is the Competence, which is just an id and a name for now.


And this is the Company with the companyValues mapping.




Is the companyValues property in the Company mapping correct like this? Or will this result in an <Integer, Integer> Map? I mean, will Hibernate understand that I need the entire Competence object as the key and return a <Competence, Integer> Map or will it return a <Integer, Integer> Map with the COMPETENCE_ID as the first integer?

Thanks!
 
Ruben Matthews
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hah! I may have once again answered my own question right after I posted it. I guess the companyValues mapping was wrong and that I must use a <index-many-to-many> tag with a class attribute instead of the plain <index> tag?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic