我不明白在我的hibernate映射設置中沒有很好的配置。 插入後很多次,我有包含在一對多關係中的鏈接表的更新。Hibernate:爲什麼每次插入之後我都會得到一個一對多關係的更新?
我不想這樣的更新。 我想更新一些與級聯或可能逆關鍵字相關的...
在我的例子,我有4個班AnalyseResult,VariationResult,變異& VariationAnnotationNGS。
AnalyseResult可以有很多VariationResults孩子。 一個父變體可以有許多VariationResultChildren。 變化可以有許多VariationAnnotationNGS子元素。
,當我試圖插入新AnalyseResult所有兒童OBJETS連着做這樣的事情
方法annoted @Transactionnal AnalyseResultBo.save(){AnalyseResultDao.save()}
對於每個新的VariationResult插入,有一個Variation的更新。 (變化已經存儲(在DB堅持)和reatached到transcient對象VariationResult。
這是我的映射。什麼是我需要改變,以使更新disapear插入後?
感謝
<!--AnalyseResult -->
<class name="com.clb.genomic.lyon.model.analysis.AnalyseResult" table="CORE_analyseResult" >
<set name="ngsVariationResults" table="NGS_variationResult" inverse="true" lazy="true" cascade="all">
<key>
<column name="id_analyseResult_fk" not-null="true" />
</key>
<one-to-many class="com.clb.genomic.lyon.model.ngs.VariationResultNGS" />
</set>
</class>
<!--VariationResultNGS -->
<class name="com.clb.genomic.lyon.model.ngs.VariationResultNGS" table="NGS_variationResult" >
<many-to-one name="analyseResult" class="com.clb.genomic.lyon.model.analysis.AnalyseResult" cascade="all" >
<column name="id_analyseResult_fk" not-null="true" />
</many-to-one>
<many-to-one name="variation" class="com.clb.genomic.lyon.model.ngs.VariationNGS" cascade="all" > <!-- cascade="all" enlever évite le update mais fait foire le insert completement-->
<column name="id_variation_fk" not-null="true" />
</many-to-one>
</class>
<!--Variation-->
<class name="com.clb.genomic.lyon.model.ngs.VariationNGS" table="NGS_variation" >
<set name="variationAnnotations" table="NGS_variationAnnotationEav" inverse="true" lazy="false" cascade="all">
<key>
<column name="id_variation_fk" not-null="true" />
</key>
<one-to-many class="com.clb.genomic.lyon.model.ngs.VariationAnnotationNGS" />
</set>
<set name="variationResults" table="NGS_variationResult" inverse="true" lazy="true" cascade="all">
<key>
<column name="id_variation_fk" not-null="true" />
</key>
<one-to-many class="com.clb.genomic.lyon.model.ngs.VariationResultNGS" />
</set>
</class>
<!--VariationAnnotationNGS -->
<class name="com.clb.genomic.lyon.model.ngs.VariationAnnotationNGS" table="NGS_variationAnnotationEav" >
<many-to-one name="variation" class="com.clb.genomic.lyon.model.ngs.VariationNGS" cascade="all">
<column name="id_variation_fk" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
查詢生成:
Hibernate: insert into NGS_variationResult (id_analyseResult_fk, id_variation_fk, shift, shift_confiance, shift_type, coverage, a_obs, c_obs, g_obs, t_obs, filter_tool, filter_custom, is_automat_valid, is_research_valid, is_clinic_valid, comment) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into NGS_variationResult (id_analyseResult_fk, id_variation_fk, shift, shift_confiance, shift_type, coverage, a_obs, c_obs, g_obs, t_obs, filter_tool, filter_custom, is_automat_valid, is_research_valid, is_clinic_valid, comment) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update NGS_variation set nucleotide_change=?, aminoAcid_Change=?, ref=?, alt=?, chr=?, position=?, strand=?, analyseDict_version=? where id=?
Hibernate: update NGS_variation set nucleotide_change=?, aminoAcid_Change=?, ref=?, alt=?, chr=?, position=?, strand=?, analyseDict_version=? where id=?