I also tried this:
Code:
<any name="parent" meta-type="class" id-type="long">
<column name="PARENT_CLASS" />
<column name="PARENT_ID" />
</any>
But this seems not working with the <map> collection of class A1 and A2. Basically, the mapping will generate a table for class C like this:
<column unid>
<column parent_class>
<column parent_id>
<column parentid>
The last column is created because there is a <key column="parentId"> line in the <map> statements for classes A1 and A2.
When I call C.setParent(A1) and persist the objects, the "parentId" column is empty because it is not in the "many-to-any" mapping.
If I change the key to <key column="parent_Id"/> (which is same as the "any" declaration), I will get "duplicate column name" error.
So, can I use java.util.Map for one-to-many collections after all if there is an "any" on the "many" end?
Dan