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;