Hy there !! =)
I'm practiving EHCache with Hibernate...and I would like to know something.
Here are my problem :
I have a class MyClass. Its mapping file declares it cached in 2ndLevel EHCache cache.
We have one Hibernate session by user (by HTTPSession). Now, imagine two users.
The first one call a hibernateSession.iterate(hqlQuery). It loads the data from the DB and put it in the 2ndLevel cache. Ok. Now, the second user comes and call hibernateSession.iterate(hqlQuery). I see in the log that it loads all the data from the 2ndLevel cache. Ok. That's all what I want for now. BUT, FROM HERE IS MY PROBLEM.
In each session, if I wanna get the object with the same id and I make a System.out.println(myObject.toString());, I see that it's not the same object in memory (it's not the same adress after @).
So, is it right ? Does this 2nd Level cache not share the objects in memory but gives clones to requesters ?
From this point I have another problem. When my first user make an update then commit on an object, the second user doesn't see the change in his HTTPSession. Do I have to make a hibernateSession.refresh(myObject); ?
Thank you !! and sorry for this pandemoniumic topic... ;o)
|