Hi folks.
I'm trying to use the @MapKey in the following way:
Code:
@Entity
public class Image {
...
@OneToMany(mappedBy = "image")
@MapKey(name = "property.name")
private Map<String, PropertyValue> properties = new Hash Map<String, PropertyValue> ();
....
}
@Entity
public class Property {
...
@Basic
private String name;
....
}
@Entity
@IdClass(PropertyValuePk.class)
public class PropertyValue {
...
@Id
private Property property;
@Id
private Image image;
@Basic
private String value;
....
}
@Embenddable
public class PropertyValuePk {
....
@ManyToOne
private Property property;
@ManyToOne
private Image image;
....
}
But it's not working as expected. Is there a way or a workaround to achieve this?
Thanks.