Hibernate version: 3.2.0.ga
Annotations version: 3.3.0.GA
I have a UfDTO with composite key: "estado" and "pais"
"pais" is a manyToOne with PaisDTO.
here are the codes:
UfDTO.java
Code:
@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 and sets.....
}
}
PaisDTO.java
Code:
@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 and sets
}
And i got this error....
Full stack trace of any exception that occurs:Code:
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)
I don't know what i'm doing wrong anymore..