-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: JPA Mapping of own Class (HashMap)
PostPosted: Tue Nov 23, 2010 11:07 am 
Newbie

Joined: Tue Nov 23, 2010 10:52 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.