在我的项目中,我最近注意到最近的映射会导致“Reglement”对象的特定行为(抱歉,法语代码)
当我们读取“Reglement”对象而没有任何修改子对象“ventilationDepenses”被删除并再次创建时,所以“Reglement”对象被设置为状态(版本)为已修改
Hibernate: update MOUVEMENT_FINANCIER set DATE_VERSION=?, COMMENTAIRE=?, DATE_ANNULATION=?, DATE_CREATION=?, TYPE=?, MODE_PAIEMENT=?, MONTANT_MOUVEMENT=?, NATURE=?, STATUT=?, DATE_CHEQUE=?, NUMERO_CHEQUE=?, INDIVIDUAL_OPERATION_ID=?, DATE_AUTORISATION=?, FRANCHISE=?, INDEMNISATION_PLUS=?, INDEMNITE_FORFAITAIRE=?, MONTANT_PROPOSE=?, OBJET_REGLEMENT=?, REFERENCE_LIEE=?, SOLDE_REGLEMENTS_BENEFICIAIRE=?, TAUX_T1=?, TAUX_T2=?, TAUX_T3=?, TAUX_TU=?, TYPE_BENEFICIAIRE=?, TYPE_DESTINATAIRE=?, EST_SOUMIS_TVA=?, PK_MVT_FINANCIER_LIE=?, DATE_TRAITEMENT_BATCH=?, BORDEREAU_ID=?, TRANSACTION_ID=?, PK_PERSONNE_BENEFICIAIRE=?, PK_ACTEUR_BENEFICIAIRE=?, PK_ADD_COUR_REG_BENEF=?, PK_PERSONNE_DESTINATAIRE=?, PK_ACTEUR_DESTINATAIRE=?, PK_ADD_COUR_REG_DEST=?, PK_RIB=? where PK_MOUVEMENT_FINANCIER=? and DATE_VERSION=?
Hibernate: update MOUVEMENT_FINANCIER set DATE_VERSION=?, COMMENTAIRE=?, DATE_ANNULATION=?, DATE_CREATION=?, TYPE=?, MODE_PAIEMENT=?, MONTANT_MOUVEMENT=?, NATURE=?, STATUT=?, DATE_CHEQUE=?, NUMERO_CHEQUE=?, INDIVIDUAL_OPERATION_ID=?, DATE_AUTORISATION=?, FRANCHISE=?, INDEMNISATION_PLUS=?, INDEMNITE_FORFAITAIRE=?, MONTANT_PROPOSE=?, OBJET_REGLEMENT=?, REFERENCE_LIEE=?, SOLDE_REGLEMENTS_BENEFICIAIRE=?, TAUX_T1=?, TAUX_T2=?, TAUX_T3=?, TAUX_TU=?, TYPE_BENEFICIAIRE=?, TYPE_DESTINATAIRE=?, EST_SOUMIS_TVA=?, PK_MVT_FINANCIER_LIE=?, DATE_TRAITEMENT_BATCH=?, BORDEREAU_ID=?, TRANSACTION_ID=?, PK_PERSONNE_BENEFICIAIRE=?, PK_ACTEUR_BENEFICIAIRE=?, PK_ADD_COUR_REG_BENEF=?, PK_PERSONNE_DESTINATAIRE=?, PK_ACTEUR_DESTINATAIRE=?, PK_ADD_COUR_REG_DEST=?, PK_RIB=? where PK_MOUVEMENT_FINANCIER=? and DATE_VERSION=?
Hibernate: update MOUVEMENT_FINANCIER set DATE_VERSION=?, COMMENTAIRE=?, DATE_ANNULATION=?, DATE_CREATION=?, TYPE=?, MODE_PAIEMENT=?, MONTANT_MOUVEMENT=?, NATURE=?, STATUT=?, DATE_CHEQUE=?, NUMERO_CHEQUE=?, INDIVIDUAL_OPERATION_ID=?, DATE_AUTORISATION=?, FRANCHISE=?, INDEMNISATION_PLUS=?, INDEMNITE_FORFAITAIRE=?, MONTANT_PROPOSE=?, OBJET_REGLEMENT=?, REFERENCE_LIEE=?, SOLDE_REGLEMENTS_BENEFICIAIRE=?, TAUX_T1=?, TAUX_T2=?, TAUX_T3=?, TAUX_TU=?, TYPE_BENEFICIAIRE=?, TYPE_DESTINATAIRE=?, EST_SOUMIS_TVA=?, PK_MVT_FINANCIER_LIE=?, DATE_TRAITEMENT_BATCH=?, BORDEREAU_ID=?, TRANSACTION_ID=?, PK_PERSONNE_BENEFICIAIRE=?, PK_ACTEUR_BENEFICIAIRE=?, PK_ADD_COUR_REG_BENEF=?, PK_PERSONNE_DESTINATAIRE=?, PK_ACTEUR_DESTINATAIRE=?, PK_ADD_COUR_REG_DEST=?, PK_RIB=? where PK_MOUVEMENT_FINANCIER=? and DATE_VERSION=?
Hibernate: delete from VENTILATION_DEPENSES where PK_MOUVEMENT_FINANCIER=?
Hibernate: insert into VENTILATION_DEPENSES (PK_MOUVEMENT_FINANCIER, CODE_NATURE_DEPENSE, MONTANT_DEPENSE, COMMENTAIRE_DEPENSE) values (?, ?, ?, ?)
Hibernate: delete from VENTILATION_DEPENSES where PK_MOUVEMENT_FINANCIER=?
Hibernate: insert into VENTILATION_DEPENSES (PK_MOUVEMENT_FINANCIER, CODE_NATURE_DEPENSE, MONTANT_DEPENSE, COMMENTAIRE_DEPENSE) values (?, ?, ?, ?)
Hibernate: delete from VENTILATION_DEPENSES where PK_MOUVEMENT_FINANCIER=?
Hibernate: insert into VENTILATION_DEPENSES (PK_MOUVEMENT_FINANCIER, CODE_NATURE_DEPENSE, MONTANT_DEPENSE, COMMENTAIRE_DEPENSE) values (?, ?, ?, ?)
Hibernate: insert into VENTILATION_DEPENSES (PK_MOUVEMENT_FINANCIER, CODE_NATURE_DEPENSE, MONTANT_DEPENSE, COMMENTAIRE_DEPENSE) values (?, ?, ?, ?)
它似乎与“ventilationDepenses”的映射相关联,尤其是lazy = false。我想了解我们的映射中发生了什么以及出了什么问题。
以下是映射的一部分。
<id name="pk" type="integer" column="PK_MOUVEMENT_FINANCIER" unsaved-value="null">
<generator class="com.prima.solutions.primaclaims.core.dao.impl.PkGenerator">
<param name="table">SEQUENCE</param>
<param name="primary_key_column">ENTITE</param>
<param name="primary_key_value">MOUVEMENT_FINANCIER</param>
<param name="value_column">NUMERO</param>
</generator>
</id>
<discriminator column="CLASSE" type="integer" />
<timestamp column="DATE_VERSION" name="version" unsaved-value="null" />
<property name="commentaire" column="COMMENTAIRE" />
<property name="dateAnnulation" type="timestamp" column="DATE_ANNULATION" />
....
<subclass name="com.prima.solutions.primaclaims.core.modele.sinistre.financier.Encaissement" discriminator-value="2">
<property name="natureRecuperation" column="NATURE_RECUPERATION" />
<property name="typeEmetteur" column="TYPE_EMETTEUR" />
<property name="bankName" column="NOM_BANQUE" />
<property name="accountOwner" column="TITULAIRE_COMPTE" />
<property name="transferLabel" column="LIBELLE_VIREMENT" />
....
</subclass>
<subclass name="com.prima.solutions.primaclaims.core.modele.sinistre.financier.Reglement" discriminator-value="1">
<property name="dateAutorisation" type="timestamp" column="DATE_AUTORISATION" />
<property name="franchise" column="FRANCHISE" />
<property name="indemnisationPlus" column="INDEMNISATION_PLUS" />
<property name="indemniteForfaitaire" column="INDEMNITE_FORFAITAIRE" />
...
<many-to-one name="beneficiaire" column="PK_PERSONNE_BENEFICIAIRE"
class="com.prima.solutions.primaclaims.core.modele.referentiel.personne.Personne" cascade="none" fetch="join" lazy="false"/>
...
<set name="ventilationDepenses" table="VENTILATION_DEPENSES" cascade="all,delete-orphan" lazy="false">
<key column="PK_MOUVEMENT_FINANCIER" not-null="true" />
<composite-element class="com.prima.solutions.primaclaims.core.modele.sinistre.financier.Depense">
<property name="nature" column="CODE_NATURE_DEPENSE"/>
<property name="montant" column="MONTANT_DEPENSE" />
<property name="version" column="DATE_VERSION"/>
<property name="commentaire" column="COMMENTAIRE_DEPENSE"/>
</composite-element>
</set>
</subclass>
</class>
答案 0 :(得分:0)
在somme调查之后,似乎使用复合元素会导致事务中的删除/插入语句。
映射已更改为定义一对多映射和对象的实体类&#34; VentilationDepenses&#34;
<class name="com.prima.solutions.primaclaims.core.modele.sinistre.financier.MouvementFinancier" table="MOUVEMENT_FINANCIER"
discriminator-value="0" abstract="true">
...
<subclass name="com.prima.solutions.primaclaims.core.modele.sinistre.financier.Reglement" discriminator-value="1">
...
<set name="ventilationDepenses" cascade="all,delete-orphan" fetch="join">
<key column="PK_MOUVEMENT_FINANCIER" />
<one-to-many class="com.prima.solutions.primaclaims.core.modele.sinistre.financier.Depense"/>
</set>
</subclass>
</class>
<class name="com.prima.solutions.primaclaims.core.modele.sinistre.financier.Depense" table="VENTILATION_DEPENSES">
<composite-id>
<key-property name="pkReglement" column="PK_MOUVEMENT_FINANCIER" />
<key-property name="nature" column="CODE_NATURE_DEPENSE"/>
</composite-id>
<timestamp column="DATE_VERSION" name="version" unsaved-value="null" />
<property name="montant" column="MONTANT_DEPENSE" />
<property name="commentaire" column="COMMENTAIRE_DEPENSE" />
</class>