Hello:
I'm using hibernate in my application, and when i tried to load a object i have this exception:
Caused by: org.hibernate.TypeMismatchException: Provided id of the wrong type: Expected: class es.impl.Tabla2Id, got class es.impl.Tabla1Id
I'm so confuse, because I save with the same application the object i want to load, and everything was ok, so ¿why the id was right when i saved, but it's a wrong type when i load?
The hbm files are:
Tabla1.hbm.xml:
Code:
<class name="es.impl.Tabla1" table="Tabla1" schema="dbo" catalog="Catalog">
<composite-id name="id" class="es.impl.Tabla1Id">
<key-many-to-one name="tabla3" class="es.impl.Tabla3">
<column name="idTabla3" />
</key-many-to-one>
<key-property name="nif" type="java.lang.String">
<column name="NIF" length="9" />
</key-property>
</composite-id>
<one-to-one name="tabla2" class="es.impl.Tabla2"/>
<property name="hombres" type="java.lang.String">
<column name="Hombres" not-null="true" />
</property>
...
</class>
Tabla2.hbm.xml
Code:
<class name="es.impl.Tabla2" table="Tabla2" schema="dbo" catalog="Catalog">
<composite-id name="id" class="es.impl.Tabla2Id">
<key-many-to-one name="tabla1" class="es.impl.Tabla1">
<column name="idTabla3" />
<column name="NIF" length="9" />
</key-many-to-one>
</composite-id>
...
</class>
Tabla3.hbm.xml
Code:
<class name="es.impl.Tabla3" table="Tabla3" schema="dbo" catalog="Catalog">
<id name="idTabla3" type="java.lang.Integer">
<column name="idTabla3" />
<generator class="identity" />
</id>
<set name="tabla1" inverse="true">
<key>
<column name="idTabla3" not-null="true" />
</key>
<one-to-many class="es.impl.Tabla1" />
</set>
.....
</class>
In the hava code, i search wih the Tabla3 class, and when i do:
Iterator<Tabla1> it = tabla3.getTabla1().iterator();
i got the exception... Really, i don't understand why, if i do a get of Tabla1, the hibernate exception expect a Tabla2Id.... Someone can help me, please?