-->
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.  [ 2 posts ] 
Author Message
 Post subject: Explicit persistence
PostPosted: Wed Oct 17, 2007 8:29 am 
Newbie

Joined: Mon Jan 02, 2006 9:57 pm
Posts: 7
I understand the default behavior of NHibernate is to detect changes to entities and automatically persist them. How would I go about changing this behavior so only explicitly requested entities are persisted? Would this require a new implementation of ISession, can it be done by using the FindDirty method of an interceptor or am I missing the best method? Or is NHibernate not really suited towards this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 10:56 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
I went the route you're looking at and discovered that it's not really a good idea. If you don't want an object's state tracked then either don't persist it, or, after it's persisted or loaded then remove it from the session or close the session.

If you want to choose to re-persist changes later you can re-associate the transient object with a session using SaveOrUpdate to get the changes into the database.

Cheers,

Symon.


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