-->
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.  [ 1 post ] 
Author Message
 Post subject: Custom events on domain objects loaded over dif sessions...
PostPosted: Sun Feb 12, 2006 10:08 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 6:49 pm
Posts: 49
I am writing a complex windows forms application with lots of ways to view and edit each domain object.
All of my domain objects implement INotifyPropertyChanged (ie, they all have a PropertyChanged event) so that when properties are changed, it is reflected in all the appropriate places.
My object model is selected from the database in lots of separate on-demand sessions (I don't want to load the entire thing on start-up as it is quite large).

To use the common Blog/BlogItem example, if I list all Blogs in one session, then all BlogItems in another session, BlogItem.Blog is never one of the objects loaded in the first list.

Code:
foreach (Blog blog in Logic.ListBlogs())
    foreach (BlogItem item in Logic.ListBlogItems())
        Console.WriteLine(blog == item.Blog);

Both Logic methods above create and dispose their own sessions. Every line written to the console reads False.

I understand that this is perfectly normal behaviour (which is why I have overridden the Equals method on my objects). However my problem is if I register a PropertyChanged event in a Blog object loaded in the second session, then edit the equivalent object loaded in the first, the event obviously isn’t fired (since they are actually separate objects in memory).

What I really need is only one object instance created for any given primary key, no matter what session it is referenced in. I was hoping that the HashtableCacheProvider would achieve this, but nothing seemed to change when I switched it on (how would I tell if it is operating correctly?).
Is there a solution to my problem other than having a static property change registry (and hence adding another level of coupling between my domain and UI)?


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

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.