I have code similar to what is below. During runtime, when I do getVersions() it is returning it with the keys of the Map as Integer instead of a String. I can compile, but at Runtime get ClassCastException because I'm expecting a String value instead of Integer.
The only thing I can think of is there is a problem and something strange going on with @MapKey. The id is an Integer primary key of the Version class and that is how I want it related in the database. Using tools to read the annotations and create tables. But in my Java Map I want the key to be another String value of a field in the Version Class.
Code:
@Entity
public class Software {
@OneToMany(mappedBy="software")
@MapKey(name="id")
public Map<String, Version> getVersions() {
return versions;
}
}