-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping my map
PostPosted: Fri Jul 16, 2004 2:38 pm 
Beginner
Beginner

Joined: Tue Jun 29, 2004 3:44 pm
Posts: 43
I'm using Hibernate 2.1.3 to persist the project I'm working on to a MySQL db. I have a collection class that I've written that maps a HashMap and adds some methods to it. I've used it in a few places and need to persist the classes that it holds.

Can I do this with a UserType or CompositeUserType? I've only seen how to persist basic types with these classes. Can I persist the contained HashMap in a UserType?

Alternately, is it possible (or sane) to write multiple mapping files for each case in which the class is used? It always has Calendars as keys, and some specific type of object as values, but the value objects change from use to use.

Any help is very much appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 16, 2004 5:38 pm 
Beginner
Beginner

Joined: Tue Jun 29, 2004 3:44 pm
Posts: 43
This was so much easier than I expected. Hibernate rocks (once you figure out how to use it)!

In case anyone else has the same question, I ended up using the component tag. I didn't have to write a UserType or even map the collection class. It makes sense (now) because it finally became clear that it wasn't an entity object.

Anyway, I added this to the hbm file of the class that uses my TemporalCollection class:

Code:
      <!-- delivery addresses: -->
      <component name="deliveryAddresses" class="eg.libraries.collections.TemporalCollection">
         <map name="contents" table="delivery_addresses">
            <key column="account_id"/>
            <index column="position" type="calendar"/>
            <many-to-many column="address_id" class="eg.contactable.ContactPoint"/>
         </map>
      </component>


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

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.