Hey guys,
I'm trying to map my own class (MilitaryUnitData) with a HashMap:
CityData:
Code:
public class CityData {
...
private Map<MilitaryUnitData, Integer> military;
...
public void setMilitary(Map<MilitaryUnitData, Integer> military) {
this.military = military;
}
@OneToMany(mappedBy = "homeCity")
public Map<MilitaryUnitData, Integer> getMilitary() {
return military;
}
...
MilitaryUnitData:
Code:
public class MilitaryUnitData {
...
@ManyToOne
public CityData getHomeCity() {
return homeCity;
}
...
public void setHomeCity(CityData homeCity) {
this.homeCity = homeCity;
}
...
I get the following error:
Code:
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: worldOfJingu.CityData.military[java.lang.Integer]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1071)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:602)
at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:79)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1163)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)
... 10 more
The question is: Which annotations do I have to use, thus I'm able use my class with the HashMap?
Thanks in advance!
Schnagga