|Using generic and specific relationships [message #491282]
||Tue, 13 October 2009 23:24
| Brendan Haverlock
Registered: July 2009
I am doing something a little interesting that I think is a perfectly valid use case. Now, I want to start off by saying that I believe this is an issue with caching only, as when I bounce the app server, everything already stored works perfectly fine.
Now I have this base class, let's call it A. A can have a generic relationship to other A's through a relationship table that contains both a reference to a source A and a target A and some other attributes as well. So, any A can have a list of these relationships.
Now let's take two implementing classes of A, B and C. Now, I when I create a B and C I want to relate B to C through this list of relationships in the base class. So, naturally I add the relationship object from B to C to the list of relationships in the base class.
Now for performance reasons, whenever I want to find the "children" C of B, I don't want create a new accessor method in B to go through every relationship and return a list of only C. I would rather have a direct List<C> in B that is automatically updated when I add to the base classes list of relationships.
Now, when I process some data through, the list of generic relationships has all the correct data, but my list of C on class B is empty. Once I bounce the app server, of course both lists are correct. I don't know how to handle this because I don't think I can add to BOTH those lists when I am persisting new data because it might think the object is new and needs to persist a duplicate copy.
Any insight into this obscure use case would be very appreciated!
Powered by FUDForum
. Page generated in 0.02538 seconds