Hi!!
I'm having a problem and need help (huge help!!).
I'll explain the context.
Tables (..table names are in spanish... ups!!):
Code:
TABLE Carrera {
id_carrera: PK
....
}
TABLE Materia {
id_materia: PK
id_carrera: PK
id_departamento: FK
....
}
TABLE Departamento {
id_departamento: PK
....
}
TABLE Integracion {
id_materia: PK
id_carrera: PK
id_materia_padre : PK
}
Quote:
"id_materia_padre" refers to "id_materia" in Table "Materia"..
"Integracion" would be a table to represent a "many-to-many" relationship between "Materia" and
"Materia" (same entities..), but an exception occurs:
org.hibernate.MappingException:
Repeated column in mapping for collection: com.epidataconsulting.test.Materia.materiasCorrelativas column: ID_CARRERA
Materia.java:
Code:
public class Materia implements Serializable {
private int id;
private String nombre;
private int creditos;
private String contMin;
private String objetivo;
private Departamento departamento;
private Set materiasCorrelativas = new HashSet();
private Carrera carrera;
.....
}
Mapping file: (Materia.hbm.xml)
Code:
<hibernate-mapping package="com.epidataconsulting.test">
<class name="Materia" table="MATERIA">
<composite-id>
<key-property name="id" column="ID" type="integer" />
<key-many-to-one name="carrera" class="Carrera" column="ID_CARRERA"/>
</composite-id>
<property name="nombre" column="NOMBRE" type="string" length="20" />
<property name="creditos" column="CREDITOS" type="integer" />
<property name="contMin" column="CONT_MIN" type="string" length="20" />
<property name="objetivo" column="OBJETIVO" type="string" length="20" />
<many-to-one name="departamento" class="Departamento"
cascade="all" outer-join="auto" not-null="true"
fetch="join" column="ID_DEPARTAMENTO" />
<many-to-one name="carrera" class="Carrera"
cascade="none" outer-join="auto"
column="ID_CARRERA" not-null="true"
fetch="join" />
<set name="materiasCorrelativas" table="MATERIA_CARRERA" inverse="true">
<key >
<column name="ID_MATERIA" />
<column name="ID_CARRERA" />
</key>
<many-to-many class="Materia">
<column name="ID_MATERIA_PADRE"/>
<column name="ID_CARRERA" />
</many-to-many>
</set>
</class>
</hibernate-mapping>
After looking for an answer in google i found out that there's a bug related to this issue.
Is there a way to solve this? ... i can't change the column name because the entities are
the same ones....
P.S.: Sorry for my english!!