-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: cascade=none not working with many to one relation
PostPosted: Wed Oct 26, 2005 11:16 am 
Beginner
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 11:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is correct behavior.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 11:32 am 
Beginner
Beginner

Joined: Fri Nov 19, 2004 11:38 am
Posts: 29
Hi,
If cascade=none doesn't ignore the association when persisting the object, what is it used for in a many-to-one relation ?
Why is this behaviour changed from H2 to H3 ?

Thank U very much
Simone


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 4:12 pm 
Newbie

Joined: Mon Oct 17, 2005 3:42 pm
Posts: 17
You updated an object that you got from the session (however indirectly), so hibernate persists that change. I see no cascade here.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 5:46 am 
Newbie

Joined: Thu Dec 16, 2004 12:56 pm
Posts: 9
I tested the example above, with a different behavior from Hibernate 2.1 a Hibernate 3.0.
In the first case, I don’t see any update to the parent class (TblFondi).
What’s wrong?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.