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.  [ 4 posts ] 
Author Message
 Post subject: Prevent implicit updates?
PostPosted: Tue Aug 23, 2005 4:01 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
I'm trying to work this out, have read through everything I can lay my hands on and am still trying to work out an ideal solution to this problem - I don't want any object in my session (whether new or loaded) to be updated without my explicitly calling save or update for that specific object.

I have objects that rely on data that is created by triggers in the database which needs to be immediately available, so when they are explicitly saved I need to flush the session and do a refresh to reload the data into the object <i>but I don't want any other modified objects to be written to the database when I call the flush</i>.

I've looked into using the ILifecycle OnUpdate callback but it's not called unless an explicit update is done, so I can't use the veto there, and the Interceptor approach doesn't let you veto.

My fallback is looking like having to create a internal field to replicate each field accessor that NHibernate uses, create a save method for each of my objects and have an interceptor copy the fields from the internal replicas to the NHibernate fields on save or update and vice versa on load. Mind you, I think this is a nasty kludge.

Are there any alteratives anyone can suggest?

Cheers,

Symon.


Top
 Profile  
 
 Post subject: Re: Prevent implicit updates?
PostPosted: Tue Aug 23, 2005 8:37 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
"implicit updates" (called "transparence persistence") works at Session level.

So if you don't want your dirty entities to be transparently persisted, you can either use Session.Evict() or use another Session instance.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 9:02 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Ah well.

At the moment I am evicting, however from an efficiency standpoint it gets a little ugly because I can't use lazy loading. I would much prefer to allow the objects to be modified while they're still members of the session so that the lazy loading is available but "turn off" transparent persistence (thanks for the terminology tip!) somehow.

In effect I want to allow an object to be loaded or saved but then have all changes ignored by the persistence framework unless the object is explicitly saved.

No other options?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 7:05 am 
Newbie

Joined: Thu Jun 01, 2006 6:59 am
Posts: 1
Hi,
i know this is quite an old post, but i have the same problem. Does anybody have a way to "turn off" the "transparence persistence" without evict an object?

The objective is to use lazy attributes on all object of a session but save only specific objects of that session.

Thanks


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