Hibernate version: 2.1.6
Mapping documents:
<class
name="com.tesla.cvrd.vap.modules.normatizacao.entity.FluxoTransporte"
table="D82FRMTT"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="D82IDFLU"
type="java.lang.Integer"
unsaved-value="0"
>
<generator class="sequence">
<param name="sequence">D82FRMTT_S00</param>
</generator>
</id>
<set
name="estadiaVagaoCargaDescarga"
table="LPFESTAT"
lazy="true"
inverse="false"
cascade="all"
sort="unsorted"
>
<key column="LPFIDFLU" />
<one-to-many class="com.tesla.cvrd.vap.modules.normatizacao.entity.EstadiaVagaoCargaDescarga" />
</set>
</class>
Why the method
saveOrUpdateCopy create a new object with new PK, but
changes the FKs in one-to-many relations instead of copying all objects from all collections that are in the main object ?
In the class FluxoTransporte I have a Set of EstadiaVagaoCargaDescarga, and when I copy a FluxoTransporte object with session.saveOrUpdateCopy( fluxoTransporteObj, newId ), Hibernate create a new FluxoTransporte object (ok at this moment) but it change the FKs (FluxoTransporte PK) in the EstadiaVagaoCargaDescarga table instead of to create new objects with the new PK.
Thanks for any help,
Sergio Stateri Jr.
sergio.jr@tesla.com.br