That approach was in fact correct...
I was just not understanding what was being generated. I thought the SQL
generated was wrong.
A better alternative however, to make it more "map" like is to use a many
to many instead of one-to-many...
as follows. This way you can have two maps mapping to the same object as a
value, in your parent object.
It adds necessary columns to the "child" or value table to do the mapping
on a one-to-many. With many to many it introduces a table to handle the
mapping.
<map name="parentChildMap" table="PARENT_CHIlD_MAP" lazy="true"
cascade="all" inverse="true">
<key column="PARENT_ID" not-null="true" />
<map-key column="KEY" type="string" />
<many-to-many class="Child" />
</map>
Michael Wiles
Java Developer
"James Mc Millan" <[EMAIL PROTECTED]>
Sent by: [email protected]
2008/02/25 15:58
Please respond to
[email protected]
To
[email protected]
cc
Subject
[CTJUG Forum] Re: Hibernate: Mapping a map with string --> object in
hibernate
Hello
What kind of problems does it give? Does it throw an exception somewhere?
Does it not return what you expect?
James
On Mon, Feb 25, 2008 at 2:46 PM, <[EMAIL PROTECTED]> wrote:
How do you map a Map with key of type String and value of type Object.
i.e. another object?
This doesn't work...
<map name="parentChildMap" table="PARENT_CHILD_MAP" lazy="true" cascade=
"all">
<key column="column1" not-null="true" />
<map-key column="column2" type="string" />
<one-to-many class="Child" />
</map>
All the documentation I've found seems to say it does...
Michael Wiles
Disclaimer
Sanlam Life Insurance Limited - Reg No 1998/021121/06 - Licensed Financial
Services Provider
Disclaimer and Directors
Alternatively, send a blank email to Disclaimer
Disclaimer
Sanlam Life Insurance Limited - Reg No 1998/021121/06 - Licensed Financial
Services Provider
Disclaimer and Directors
Alternatively, send a blank email to Disclaimer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
-~----------~----~----~----~------~----~------~--~---