Hello,
I'am sorry I'am a newbie and I don't understand the docs how to map a map with entities. I have two classes Parent and Child:
Code:
public class Parent {
private Map childs = new HashMap();
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setChilds(Map childs) {
this.childs = childs;
}
public Map getChilds(Map childs) {
return this.childs;
}
}
public class Child {
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
... and the follwing table structure because of one child is able to have more than one parent:
Parents
=====
idParent | name
Parents_Childs
==========
idParent | idChild
Childs
====
idChild | name
The hashmaps of Parents should contain as key the name of the childs and as value the child objects.
My mapping doesn't work:
Code:
<class name="foo.bar.Parent" table="Parents">
<id name="id" column="idParent">
<generator class="increment"/>
</id>
<property name="name"/>
<map name="Childs" table="Parents_Childs">
<key column="idParent"/>
<many-to-many class="foo.bar.Child" column="idChild"/>
</map>
</class>
<class name="foo.bar.Child" table="Child">
<id name="id" column="idChild">
<generator class="increment"/>
</id>
<property name="name"/>
</class>
Thank you!
Best Regards