Hy everybody,
I would like save an annotated pojo to the database which has a Map property that looks like this:
Code:
private Map<String, String> settings;
Now I've read that you can do this by using a mapping like this:
Code:
<map role="ages">
<key column="id"/>
<index column="name" type="string"/>
<element column="age" type="string"/>
</map>
But I want to use annotations instead, so I began to look for examples.
If I use:
Code:
@OneToMany(mappedBy="value")
@MapKey(name="keyvalue")
public Map<String, String> getSettings() {
return settings;
}
I get an exception telling me that
Code:
Invocation of init method failed; nested exception is org.hibernate.AnnotationException:
Use of @OneToMany or @ManyToMany targeting an unmapped class:
com.xyz.core.impl.collector.AbstractCollector.settings[java.lang.String]
"value" and "keyvalue" are just random names - intended to be used as column names. Should there be specific names of fields instead?
Any suggestions on what I'm doing wrong?
Hibernate version:3.3.0.ga
p.s.: I also read about dynamic entity mode - this is NOT what I'm going for here. I want to map my HashMap field of my pojo to a database table - that's all.