Can I update an object in a composite key??
Example:
Code:
<hibernate-mapping package="br.sapiensit.cadastrounico.programas.dao.hibernate.hbm">
<class name="br.sapiensit.cadastrounico.programas.pojo.VinculoFamilia" table="TB_CDU_VINCULO_FAMILIA">
<composite-id name="id" class="br.sapiensit.cadastrounico.programas.pojo.VinculoFamiliaKey">
<key-many-to-one name="familia" column="CD_FAMILIA" class="br.sapiensit.cadastrounico.cadastrofamilias.pojo.Familia"/>
<key-many-to-one name="programaMigracao" column="CD_PROGRAMA_MIGRACAO" class="br.sapiensit.cadastrounico.programas.pojo.ProgramaMigracao"/>
<key-property name="codigoVinculoFamilia" column="CD_VINCULO_FAMILIA" type="java.lang.Long"/>
</composite-id>
<property name="flagVinculoValidado" column="FL_VINCULO_VALIDADO" type="java.lang.Short" />
<many-to-one name="pessoa" column="CD_PESSOA" class="br.sapiensit.cadastrounico.cadastrofamilias.pojo.Pessoa" />
</class>
</hibernate-mapping>
I would like to update the value of property codigoVinculoFamilia.
First I load the object:
someVinculoFamilia = session.load(someVinculoFamiliaKey);
someVinculoFamilia.getId().setCodigoVinculoFamilia(new Long(3));
session.update(someVinculoFamilia);
is this correct!?
Or should I delete the object and then insert!?!?