[RESOLVIDO] Erro em relacionamento @ManyToMany Hibernate

1 resposta
R

Pessoal,
Estou tentando fazer o relacionamento ManyToMany da classe Usuario e Depto, tabela de relacionamento (usuariodepto) . Porém está dando o seguinte erro:

09:35:34.978 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: alter table usuariodepto add constraint FK46A4EE3A7FCF3EE2 foreign key (id_depto) references usuario
09:35:34.978 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Column ‘usuario.cd_usuario’ is not the same data type as referencing column 'usuariodepto.id_depto in foreign key ‘FK46A4EE3A7FCF3EE2’.

@ManyToMany(fetch=FetchType.LAZY)
    @JoinTable(name="usuariodepto", 
    joinColumns={@JoinColumn(name="cd_usuario",nullable = false,updatable = false)}, 
    inverseJoinColumns={@JoinColumn(name="id_depto",nullable = false,  updatable = false)}) 
    private Collection <Usuario> deptocollection;

DEPTO:

@ManyToMany(fetch=FetchType.LAZY)
    @JoinTable(name="usuariodepto", 
    joinColumns={@JoinColumn(name="id_depto",nullable = false, updatable = false)}, 
    inverseJoinColumns={@JoinColumn(name="cd_usuario", nullable = false, updatable = false)}) 
    private Collection <Usuario> usuariocollection;

1 Resposta

R

Resolvido,

Estavada instaciando a collaction Depto errado:

private Collection <Usuario> deptocollection;

private Collection <Depto> deptocollection;
Criado 6 de junho de 2011
Ultima resposta 6 de jun. de 2011
Respostas 1
Participantes 1