Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge makes cached reference stale #81

Closed
ledsoft opened this issue Nov 26, 2020 · 1 comment
Closed

Merge makes cached reference stale #81

ledsoft opened this issue Nov 26, 2020 · 1 comment
Assignees
Labels

Comments

@ledsoft
Copy link
Contributor

ledsoft commented Nov 26, 2020

If an entity is cached as part of an object graph of another entity and them updated separately via em.merge, the reference in cache becomes out of sync and is not evicted, causing subsequent load of the referencing object to contain stale values.

For example, consider objectds a and b, where a has a reference to b.

The following sequence demonstrates the issue:

  1. Load a. Both a and b are put into second-level cache.
    2 Clear/close the EntityManager.
  2. Edit some attributes of b and merge it into persistence context.
  3. JOPA will evict b from cache. However, the b instance referenced by a stays in the cache.
  4. Load a. It will be fetched from cache and contain b with now stale values.
@ledsoft
Copy link
Contributor Author

ledsoft commented Feb 4, 2021

Fixed in 0.16.3.

@ledsoft ledsoft closed this as completed Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant