Beginner |
 |
Joined: Fri Nov 19, 2004 11:38 am Posts: 29
|
I'm using Hibernate 3.0.5 and noticed that the behaviour of cascade="none" in a many-to-one relation doesn't work the same.
It seems that cascade="none" is not beeing handled in H3.
I tried to download H3.1 rc2, but the result is the same. Jra pages were of no help.
Here is my short example:
TblDocumenti doc = (TblDocumenti)SessionManager.currentSession().load(TblDocumenti.class, new Long(506));
// set an attribute of the Foreign Key (father)
doc.getFnd().setDescrizione("cc");
Transaction t = SessionManager.currentSession().beginTransaction();
SessionManager.currentSession().flush();
t.commit();
Hibernate updates the Foreign key property even if the cascade property of the many-to-one relatione is setted to "none".
Here are the xml files:
TblDocumenti:
<class dynamic-update="true" lazy="false" name="TblDocumenti"
schema="GAM_ADM" table="TBL_DOCUMENTI">
<id name="id" type="long">
<column index="PK_TBL_DOCUMENTI" name="ID" not-null="true"
precision="11" scale="0"/>
<generator class="sequence">
<param name="sequence">S_470_1_TBL_DOCUMENTI</param>
</generator>
</id>
<version column="VERSION" name="version" type="integer"/>
<property column="xxx" lazy="false" name="xxx" type="string"/>
</property>
<many-to-one class="microfilm.model.TblFondi" cascade="none" lazy="false"
foreign-key="TBL_DOC_FONDI" name="fnd">
<column index="FND_CODICE" length="60" name="FND_CODICE" not-null="true"/>
</many-to-one>
</class>
TblFondi
<class name="TblFondi" lazy="false" table="TBL_FONDI"
schema="GAM_ADM" optimistic-lock="none">
<id name="codice" type="string" unsaved-value="null">
<column name="CODICE" length="60" not-null="true" index="CODICE" />
<generator class="assigned" />
</id>
<property name="descrizione" type="string">
<column name="DESCRIZIONE" not-null="true"
index="DESCRIZIONE_1" />
</property>
</class>
Thank U very much
Simone
|
|