I'm using Hibernate with Ehcache (don't think it matters, tho)..
When a user logs in I identify him by his email and I use his email for all subsequent calls.
Now, since email is not my "hibernate id" (the one I annotated with @Id
) I have to to load it with a query and thus, store it in the query cache. However, when the user logs out I can't explicitly evict him from the cache since he is stored within a region that it shares with others users that have logged in since.
My question is: Can I load the user into the 2nd level cache (thus making eviction easier) without going again to the database with the session().get(user)
method?
There is another point here, if the user is updated the query cache will become wrong for this user. I want it to be updated when I update the user