Hi all,
I have an entity called "Expediente" which has a collection of "Ambito".
Expediente hbm looks like this:
Code:
<hibernate-mapping>
<class name="es.Expediente" table="EXPEDIENTE">
<id name="id" type="java.lang.Integer">
<column name="ID" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">SQ_EXP</param>
</generator>
</id>
<property name="codigo" type="java.lang.String">
<column name="CODIGO" length="30" />
</property>
[...MORE PROPERTIES...]
<set name="Ambito" table="EXP_AMBITO" inverse="true" cascade="save-update" lazy="false" fetch="join">
<key>
<column name="ID_EXP" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="es.xunta.cptopt.sxeuweb.pojo.SxeuExpAmbitoPojo" />
</set>
</class>
</hibernate-mapping>
Ambito hbm is as follows:
Code:
<hibernate-mapping>
<class name="es.Ambito" table="EXP_AMBITO">
<composite-id name="id" class="es.ExpAmbitoId">
<key-property name="idExp" type="java.lang.Integer">
<column name="ID_EXP" precision="22" scale="0" />
</key-property>
<key-property name="idTipoAmbito" type="java.lang.Integer">
<column name="ID_TIPO_AMBITO" precision="22" scale="0" />
</key-property>
<key-property name="codigoAmbito" type="java.lang.String">
<column name="CODIGO_AMBITO" length="20" />
</key-property>
</composite-id>
<many-to-one name="sxeuExpPojo" class="es.xunta.cptopt.sxeuweb.pojo.SxeuExpPojo" update="false" insert="false" fetch="select">
<column name="ID_EXP" precision="22" scale="0" not-null="true" />
</many-to-one>
[...MORE PROPERTIES...]
</class>
</hibernate-mapping>
And when I try to persist an object from Expediente class I get an error indicating that I can't save "Ambito" without the Expediente id...
I tried without cascade="save-update" and saving Expediente first and then the Ambito collection but when later I update Expediente it tries to update the existing Ambito records that are related to the Expediente object and I get an error indicating that some of them doesn't exist, which is true because the collection has changed.
What can I do to get this working?
Thank you...