Saudações,
estou com a seguinte situação,
no UfDTO tenho um manyToOne com PaisDTO,
porém esse manyToOne também é o id do UfDTO, pois o mesmo possui como chave composta (estado e pais)
está me retornando esse erro:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: cadastros.modelo.uf.dominio.UfDTO column: pais (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:605)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:627)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:623)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:645)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:420)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at base.modelo.persistencia.HibernateUtil.<clinit>(HibernateUtil.java:61)
segue o código:
UfDTO.java
@Entity
@IdClass(UfDTO.UfPk.class)
@Table(name="\"unid-feder\"", schema="PUB")
public class UfDTO extends BaseDTO {
private static final long serialVersionUID = 1L;
@Id
private String estado;
@Id
private PaisDTO pais;
@Column(name = "\"no-estado\"")
private String nomeEstado;
public UfDTO(){
}
//gets e sets.....
@Embeddable
private static class UfPk {
/* Construtores */
public UfPk(String estado, PaisDTO pais) {
setEstado(estado);
setPais(pais);
}
/* Campos */
private String estado;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="pais",insertable=false, updatable=false)
@Fetch(FetchMode.JOIN)
@Cascade(CascadeType.PERSIST)
@NotFound(action=NotFoundAction.IGNORE)
private PaisDTO pais;
//gets e sets.....
}
}
PaisDTO.java
@Entity
@Table(name="pais", schema="PUB")
public class PaisDTO extends BaseDTO {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "\"nome-pais\"")
private String nomePais;
@Column(name = "\"nome-compl\"")
private String nomeComplementar;
@Column(name = "\"cod-internacional-pais\"")
private Integer codigoInternacional;
@Column(name = "\"cod-pais\"")
private Integer codigoPais;
//gets e sets
}
alguém ja teve esse problema?