Olá Pessoal,
Tô começando com o Hibernate agora e tenho uma dúvida simples.
Eu tenho uma classe chamada Collection que onde eu quero ter conjuntos com objetos Tag. Vejam o código:
@Entity
public class Collection {
@Id
@GeneratedValue
private Long id;
private String name;
private HashSet<Tag> fixedTags;
public HashSet<Tag> getFixedTags() {
return fixedTags;
}
public void addFixedTag(Tag tag){
this.fixedTags.add(tag);
}
public void removeFixedTag(Tag tag){
this.fixedTags.remove(tag);
}
// outros getters e setters
}
Aqui está a classe Tag:
public class Tag {
private String k;
private String v;
// getters e setters
}
Qual é a melhor maneira de anotar isso no hibernate? A relação entre Collection e Tag é unidirecional.