-->
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.  [ 8 posts ] 
Author Message
 Post subject: Mapping question
PostPosted: Mon May 05, 2008 2:45 pm 
Newbie

Joined: Tue Jan 22, 2008 4:43 pm
Posts: 7
Hi!

I'm having two classes:

Template
TemplatedView

TemplatedView holds an objectref to Template. If I change some properties on a TemplatedView-instance and also update a property on it's Template-instance (see below) and pass the TemplateView-instance to NHibernate for update, the Template-instance is also updated. Is there anyway to get rid of this behavior? Tried insert=false and update=false (see below).

TemplateView view = new TemplatedView();
view.Template.Name = "Test";
view.Alias = "FridayVw";

session.Update(view); //I don't want to persist changes made to contained objects, in example: view.Template
session.Flush();

<many-to-one name="Template" column="Rel_Template" class="Template" not-null="false" insert="false" update="false" cascade="none" />

//Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 06, 2008 2:31 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
Hi,
try it with inverse="true":


Code:
<many-to-one name="Template" column="Rel_Template" class="Template" not-null="false" inverse="true" cascade="none" />


Top
 Profile  
 
 Post subject: Not a collection...
PostPosted: Tue May 06, 2008 12:59 pm 
Newbie

Joined: Tue Jan 22, 2008 4:43 pm
Posts: 7
so inverse isn't a option.

//Daniel


Top
 Profile  
 
 Post subject: Not a collection...
PostPosted: Tue May 06, 2008 1:00 pm 
Newbie

Joined: Tue Jan 22, 2008 4:43 pm
Posts: 7
so inverse isn't a option.

//Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 06, 2008 1:59 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
cascade="none" should do the job. If it's still saved/updated, then the template object is probably already in the session. In that case either clear the session before save/update or evict the object from the session.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: cascade....
PostPosted: Wed May 07, 2008 9:48 am 
Newbie

Joined: Tue Jan 22, 2008 4:43 pm
Posts: 7
Hi!

Is there a way to easily retrieve automatically evicted objects, or do you have to explicitly call evict for each object?

//Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 07, 2008 9:59 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Not that I know of, but you could load these objects in a different session which is closed or cleared after loading.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 08, 2008 4:32 am 
Newbie

Joined: Wed May 07, 2008 8:18 am
Posts: 3
It indicates that the porblem is here;
<many-to-one name="Template" column="Rel_Template" class="Template" not-null="false" insert="false" update="false" cascade="none" />


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.