Hello I'm a newbie with the JPA-Framework. In my project I use JPA with EclipseLink and DerbyDB. It's all working for me fine. But then I would persist a HashMap, that's my problem.
The HashMap looks like (used in GameArea):
private HashMap<GameObject, ObjectContainer> gameObjects;
class GameArea:
@Entity
public class GameArea implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long OID;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private HashMap<GameObject, ObjectContainer> gameObjects;
}
class GameObject (the abstract object):
@MappedSuperclass
public abstract class GameObject implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long OID;
...
}
class ObjectContainer (the composite component):
@Entity
public abstract class ObjectContainer extends GameObject implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long OID;
...
}
My HashMap is a lookup table for objects from GameObject to GameObject (as a ObjectContainer).
I've got an exception:
Exception [EclipseLink-163] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: This mapping's attribute class does not match the collection class. [class java.util.Hashtable] cannot be assigned to [class java.util.HashMap].
Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[gameObjects]
Descriptor: RelationalDescriptor(GameArea --> [DatabaseTable(GAMEAREA)])
I don't know what it means... I'm not sure with the "OneToMany" relation...
Please can you help me?