-->
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.  [ 3 posts ] 
Author Message
 Post subject: Save/Cancel functionality (do I need N-level cache)
PostPosted: Thu Feb 16, 2006 10:00 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 2:08 pm
Posts: 23
I'm gradually realizing that in order to provide a Save/Cancel button I need an NPersist style N-level cache. What I need is to be able to create a copy of a business object that behaves exactly like an NHibernate proxy (duplicates child collections lazily) but with an in-mem object as it's datastore, not the database. Any way I can accomplish this myself today by creating my own proxy. Seems a shame to roll my own given how similar this is to Nhibernate's functionality.

Am I barking up the wrong tree? How do other people provide a Save/Cancel features?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 10:33 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
I use a struct as my backing datastore (and properties to retrieve it). Then I implement IEditable and in the corresponding BeginEdit() I make a copy of the struct to a temp location.
When CancelEdit() is called, i just replace the 'current' struct with the temp struct.
If endedit is called, I just dispose the temp struct.

This is how microsoft recommends doing it.

I hope that helps


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 11:48 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 2:08 pm
Posts: 23
The problem with disposing of the NHibernate business object returned from the session and replacing it with a new one is that the business object returned by the session is actually an NHibernate proxy with special collections that remember what changes have been made. If I simply try and update NHibnerate with the copy when the user clicks "Save" NHibernate will attempt to insert all the objects in the child collection (I think?). I tried to ask this question earlier in the forum and I didn't get a response:

If I make a binary copy of an NHibernate proxy (via binary serialization), dereference the original, and call session.Save on the copy will the behaviour be the same as if I called session.Save on the NHibernate proxy?

In other words: Does the session store a pointer to the retrieved object in the cache or does it simply use the ID?

Thanks,
Jafar


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