persistence@glassfish.java.net

Re: Some questions about HardWeak/SoftWeak cache

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Wed, 21 May 2008 22:27:29 -0400

In EclipseLink all classes within a mapped joined inheritance heirarchy
are stored in the same cache. The second method is used if you want to
find the number of instances of a certain class that are in this
particular identity map.
I'm not sure what you mean by the first method not returning the correct
number of objects in the cache?
--Gordon

jasonw41 wrote:
> Thank you very much for all the detail answers. Those really help. I just
> have a further question about getSize methods on IdentityMap. I tried the
> following two methods to get the cache size:
>
> 1) size =
> ((oracle.toplink.essentials.ejb.cmp3.EntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessorInstance().getIdentityMap(MyEntity.class).getSize();
>
> 2) size =
> ((oracle.toplink.essentials.ejb.cmp3.EntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessorInstance().getIdentityMap(MyEntity.class).getSize(MyEntity.class,true);
>
> It looks like only the second one can return the current size of the map and
> the first one returns the number of entities used to be in the cache. I have
> a glance of the source code and find the first method also "return
> cacheKeys.size();". So why the first one does not return the correct size?
>
> Cheers,
> Jason
>