-->
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: Using classes as Keys in a hibernate HashMap.
PostPosted: Sun Oct 31, 2004 12:47 pm 
Newbie

Joined: Sun Aug 31, 2003 12:04 pm
Posts: 8
Hi!

I'm having difficulty in designing a good mapping for a particular class I've used in the past. The problem class is called Document which amongst other things has a hashmap of language codes to Body's.
My problem is replicating the keys in hibernate. A Body contains a particular translation of the Document and a Language and I want to use the body.language.code as the key.

I've tried the following two index settings...

Code:
<map name="bodies">
  <key column="documentId"/>
  <index column="language" type="Language"/>
  <one-to-many class="Body"/>
</map>

Code:
<index column="language.code" type="String"/>


In the first example I was happy for the key to be a Language object instead of a String but I ended up with serialized languages in my bodies table.
I didn't expect the second example to work but maybe shows what I'm after :-)

Is it possible to achieve the mapping I'm after or is there another way I could think about the problem?

Thanks.


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.