I tried to map this three classes:
@Entity
class Photo {
...
@ManyToOne
private Map<User, Coordinate> labelledIn;
...
}
@Entity
class User {
...
@OneToMany (mappedBy ="labelledIn")
private Set<Photo> labelledPhotos;
...
}
@Embedded
class Coordinate { ... }
And I’m getting this error:
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.redex.model.Photo.labelledIn references an unknown entity: java.util.Map
Can I map this qualified association in my database? If I can’t, how can I do this in a different way?
Use
instead
@ManyToOne.As @JB Nizet said, there’s no point in having many-to-one relation to a collection.
For more details have a look here: 2.2.5.3.4. Indexed collections (List, Map).