Hibernate - @OneToMany e @ManyToOne

1 resposta
ultranine

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.

1 Resposta

ultranine

Já consegui resolver!

Criado 1 de junho de 2010
Ultima resposta 1 de jun. de 2010
Respostas 1
Participantes 1