Hello,
sorry, but this is my 3rd posting about this subject. I had tried some answers but it doesn't work.
I want to map the following class structure:
Code:
public class Template {
public HashMap containers = new HashMap();
public void setSingleContainers(Map singleContainers) {
this.containers = singleContainers;
}
Map getSingleContainers() {
return this.containers;
}
...
}
public class SingleContainer {
public String name = "";
public void setName(String name) {
this.name = name;
}
...
}
Each instance of Template can contain 0...n different SingleContainers. Each SingleContainer can be member of 1 or more Templates. So I have the following table structure:
Template
======
idTemplate
name
Template_SingleContainer
=================
idTemplate
idSingleContainer
SingleContainer
==========
idSingleContainer
name
My mapping looks like this:
Code:
<class name="foo.bar.Template" table="Template">
<id name="id" column="idTemplate">
<generator class="increment"/>
</id>
<property name="name"/>
<map name="SingleContainers" table="Template_SingleContainer">
<index column="name" type="string"/>
<key column="idTemplate"/>
<many-to-many class="foo.bar.SingleContainer"
column="idSingleContainer"/>
</map>
</class>
...
I need to use the name SingleContainer.name as key for the HashMap containers but I don't know how to do that. All what I got is this exception:
Caused by: java.sql.SQLException: Column not found, message from server: "Unknown column 'template0_.idSingleContainer' in 'field list'"
What's that: template0_ ?
Searching in the docs or in the forum doesn't help.
It would be nice If you can help me or give me a short example.
Thank you very much.
Regards