@JoinTable

2 respostas
rafaelrodrigues1607

Pessoal, criei a seguinte tabela de relacionamento

@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinTable(name = "intimacao_pendencia", schema = "public", joinColumns = { @JoinColumn(name = "id_intimacao", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "id_tipo_intimacao", nullable = false, updatable = false) }) private Set<TipoIntimacao> tipoIntimacao = new HashSet<TipoIntimacao>(0);

Gostaria de saber se posso colocar nessa tabela um outro campo além do ID das duas tabelas.

2 Respostas

Hebert_Coelho

Vc tentou? Oq aconteceu?

OBS.: Pra que isso? new HashSet(0);

rafaelrodrigues1607

Tentei criar um novo campo chamado situacao_intimacao

@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinTable(name = "intimacao_pendencia", schema = "public", joinColumns = { @JoinColumn(name = "id_intimacao", nullable = false, updatable = false), @JoinColumn(name = "situacao_intimacao", nullable = false, updatable = false)}, inverseJoinColumns = { @JoinColumn(name = "id_tipo_intimacao", nullable = false, updatable = false) }) private Set<TipoIntimacao> tipoIntimacao = new HashSet<TipoIntimacao>(0);

Mas ocorreu o seguinte erro:

A Foreign key refering br.com.infosolo.snit.entidades.Intimacao from br.com.infosolo.snit.entidades.TipoIntimacao has the wrong number of column. should be 1
Criado 6 de março de 2012
Ultima resposta 6 de mar. de 2012
Respostas 2
Participantes 2