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