Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Using generic and specific relationships
Using generic and specific relationships [message #491282] Tue, 13 October 2009 23:24 Go to next message
Brendan Haverlock is currently offline Brendan Haverlock
Messages: 46
Registered: July 2009
Member
Hi all,

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!

Thanks!

-Brendan Haverlock
Re: Using generic and specific relationships [message #491490 is a reply to message #491282] Wed, 14 October 2009 19:10 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan Haverlock
Messages: 46
Registered: July 2009
Member
Would a feasible solution be to make the list<C> in B a CascadeType.REFRESH only, and add to both A's relationship list and B's List<C> when adding a C?

LOL sorry about the confusing use case, but it's really hard to portray in a simple way.
Re: Using generic and specific relationships [message #492003 is a reply to message #491490] Sat, 17 October 2009 00:09 Go to previous messageGo to next message
Brendan Haverlock is currently offline Brendan Haverlock
Messages: 46
Registered: July 2009
Member
Ugh, it still tries to persist the relationship if I add C to the list on B. I try making it Transient and it doesn't let my app server start because it's saying Transients can't have mappings Sad
Re: Using generic and specific relationships [message #492030 is a reply to message #492003] Sat, 17 October 2009 09:09 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
Would a "find" work instead of keeping a list?
Re: Using generic and specific relationships [message #492044 is a reply to message #492030] Sat, 17 October 2009 16:08 Go to previous message
Brendan Haverlock is currently offline Brendan Haverlock
Messages: 46
Registered: July 2009
Member
Yea, but I'd have to do that in any of my action beans and whatnot that would want to display this information. I am thinking about just making a transient variable that is cached on the first get and then always kept in sync. Seems like a pain, but it would be better then doing a bunch of expression builders whenever I needed the data. I was just hoping there would be a first class feature that would support some oddball use case like this where you need two copies of the same data but one not persisted and only containing a subset of the other.
Previous Topic:MOXy - How to map multiple nodes with the same path?
Next Topic:EMF/Teneo and EclipseLink integration
Goto Forum:
  


Current Time: Sat Oct 25 03:00:42 GMT 2014

Powered by FUDForum. Page generated in 0.07515 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software