I have a table who has a composite key(picture one) and one of them is a foreign key that refers another table (picture two)
How can I map this using hibernate???
The code below is the code I made. But its is not working. I think it is not the way to make this map.
The class CamposObrigatoriosID is the class that have
@Embeddable
public class CamposObrigatoriosID implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name=“PERFIL_CMPOBR”)
private Long perfil;
@Column(name=“ORDEM”)
private Long ordem;
@Column(name=“NOMETABELA”)
private String nomeTabela;public Long getPerfil() {
return perfil;
}
...
@Override
public boolean equals(Object arg0) {
if(arg0 instanceof CamposObrigatoriosID) {
CamposObrigatoriosID that = (CamposObrigatoriosID) arg0;
return this.perfil.equals(that.perfil) && this.ordem.equals(that.ordem) && this.nomeTabela.equals(that.nomeTabela);
}
return false;
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return perfil.hashCode() + ordem.hashCode() + nomeTabela.hashCode();
}
@Embeddable
public class CamposObrigatoriosID implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name=“PERFIL_CMPOBR”)
private Long perfil;
@Column(name=“ORDEM”)
private Long ordem;
@Column(name=“NOMETABELA”)
private String nomeTabela;
.....
@Entity
@Table(name=“USUARIO_PERFIL”)
public class UsuarioPerfil {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name=“CODIGO_USRPERFIL”)
private Long id;
@Column(name=“DESCRICAO_USRPERFIL”)
private String desccricaoUsrPerfil;
...
Error: SQLState:42000, ISC error code:335544351