I've been banging my head on this problem all day long, as has a co-worker.
I have a class, A, which contains a Map. The Map has class B as a key, and value of an Integer (counting how many of class B are required to pass some business rule).
Of course, I'd like to persist this map. The end result of our mappings is that the tables created for class A have no reference at all to the map.
We're using XDoclet, but even by hand, we get the same result. The relevant section of the hbm is:
<map
name="requiredBs"
table="RequiredBs"
lazy="false"
sort="unsorted"
cascade="save-update"
>
<key
column="aId"
>
</key>
<index-many-to-many
class="com.domain.B"
column="B"
/>
<element
column="numBs"
type="integer"
not-null="false"
unique="false"
/>
</map>
In looking at other classes that we've addressed, in NO cases where we are using a map has there been any indication of the association between the containing class and the table for the map itself. I even went so far as to look at "Hibernate In Action" (page 214), and add in a Set attribute exactly as their example shows, and to manually edit the hbm. The result was the same.
We've looked, and looked ...... googled, searched the forums, consulted books. I'm pulling my hair out!
Any suggestions, thoughts?
j
|