|Problem with Bidirectional relationship and Cache [message #1232227]
||Thu, 16 January 2014 08:29
| Noa Drach
Registered: November 2012
This will be a long one because I tried to add all the relevant data...|
I'm using eclipslink 2.4.2M3 and mysql 5.5
we use static weaving and Eager relations are not being weaved
I have the following entities:
- User can have permissions on a Strategy.
- A Strategy is Connected to at least an owner=User
- A Strategy can be connected to an Assignee=User
- Which means that a Strategy also has 2 members that can point to a User
the link between them is:
User->Permission - OneToMany - loaded lazily
Strategy->Permission - OneToMany - loaded lazily
Permission->User - ManyToOne
Permission->Strategy - ManyToOne
now i make sure handling all the Bidirectional relationships in all 3 entities and i have the following scenario.
my interaction with my app is done using REST.
the basic scenario is:
in my test i have 4 users
1. create a strategy
2. connect owner and maybe assignee
3. count how many strategies each of the 4 users has
4. change owner or assignee or both
5. count how many strategies each of the 4 users has
6. the test compares the results of steps 3 & 5 to see if it failed or not
now the test fails only in the 2 scenarios where both owner and assignee were replaced to users that didn't have permissions earlier.
in the db all the info appears correctly
- Before - User A is the owner; After - User B is the owner and User C is the assignee
- Before - User A is the owner and User B is the assignee; After - User C is the owner and User D is the assignee
The solution we have right now is to evict the user from the cache when we add a new permission.
But we don't like this solution because we don't know what caused the issue - so in our investigations we encountered another solution that actually increases the confusion:
If we change the relation between Strategy and permission to be loaded Eagerly the problem is solved - remember that Eager is not being cached...
but if we evict the Strategy from the cache instead of evicting the User the problem isn't solved.
I wanted to consult with you how to find the root cause of the problem given the 2 different solutions, because I can't understand how those 2 different solution have the same outcome.
Powered by FUDForum
. Page generated in 0.13358 seconds