-->
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: Need help on how to map a collection inside a map
PostPosted: Mon Jul 09, 2007 6:53 pm 
Newbie

Joined: Thu Mar 15, 2007 6:02 pm
Posts: 2
Location: Seattle
Hi,
I am new to Hibernate so please redirect me if I am sending to the wrong email or it’s already documented somewhere. But I tried and couldn’t find anything useful.

I wonder if anyone has used Hibernate to map Java Map collection.

I have the below Java Map collection. I couldn’t find any documentation on how to map it in Hibernate.
Public ClassC{

Public Map<ClassA, Collection<ClassB>> headacheMap;
}

FYI. If the element is ClassB instead of Collection<ClassB>, we can use the below mapping:
Public ClassC{

Public Map<ClassA, ClassB> normalMap;
}

ClassC.hbm.xml:
<class name=”ClassC”>
<map name=”normalMap” table=”mapping_table”>
<key column=”id”/>
<map-key-many-to-many class=”ClassA”/>
<many-to-many class=”ClassB”/>

</map>
</class>

The problem is when we wrap ClassB with a collection, how do we write the mapping file?

One way is to define a classD to wrap Collection<ClassB>. But I am just wondering if there is any way without changing my Java implementation.

Any insight is appreciated. Thanks!

-Chang




Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: SQL Server 2005

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

_________________
-Chang


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.