I’m trying to annotate this :
public class Keyword {
@Id @GeneratedValue
private Integer id;
//Missing annotation
private Map<Keyword, Integer> keywordRelated;
}
I found this example but they don’t deliver the relational model, and it’s not the exactly same model. And I can’t figure out how their tables are.
Following tells only how to map Map which does have entity as a key (depending about case can be that there is better solutions, like intermediate object with ratio).
@ElementCollection is designed for mapping such a collection. @OneToMany cannot be used when value is not entity.
By default following mapping
Maps to following table in database (assuming that name of table for Keyword entity is Keyword and not affected via @Table-annotation):
If default naming for database tables and columns is not sufficient, those can be customized as follows: