You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Fr...@capgroup.com on 2008/04/03 19:44:17 UTC

EntitymanagerFactoryImpl.getStoreCache(String cacheName) problem

The EntitymanagerFactoryImpl.getStoreCache(String cacheName) . This method
calls DataCacheManager.getDataCache(cacheName).
I think it should call DataCachemanager.getDataCache(cacheName, true) to
make sure if the cache does not exist it will get created. Unless of course
this is the behavior specified by JPA spec. This is important becuase
otherwise we get StoreCacheImpl reference with a DelegatingDataCache
reference with a null cache reference inside.

An alternative to make this work would be to instanciate all the namedCache
at startup - but this does not sound like a good idea to me because noone
can know upfront whcih cache will actually be used. The current
DataCacheManagerImpl does not suffer from this issue becuase there is only
one dataCache.
But in the case of a DataCacheManager implementation with multiple named
cache - which is what I am implementing now - then this does not work
anymore.
Moreover, I cannot chnage the behavior of getDataCache(String name) becuase
the interface says:
    /**
     * Return the named data cache, or null if it does not exist.
     */
    public DataCache getDataCache(String name);


Could this code change be made in the future?

F


Re: EntitymanagerFactoryImpl.getStoreCache(String cacheName) problem

Posted by Patrick Linskey <pl...@gmail.com>.
That's not a spec API, so we can change it / augment it as we see fit.
I don't see any reason not to just change that code as you described.

-Patrick

On Thu, Apr 3, 2008 at 10:44 AM,  <Fr...@capgroup.com> wrote:
>
>  The EntitymanagerFactoryImpl.getStoreCache(String cacheName) . This method
>  calls DataCacheManager.getDataCache(cacheName).
>  I think it should call DataCachemanager.getDataCache(cacheName, true) to
>  make sure if the cache does not exist it will get created. Unless of course
>  this is the behavior specified by JPA spec. This is important becuase
>  otherwise we get StoreCacheImpl reference with a DelegatingDataCache
>  reference with a null cache reference inside.
>
>  An alternative to make this work would be to instanciate all the namedCache
>  at startup - but this does not sound like a good idea to me because noone
>  can know upfront whcih cache will actually be used. The current
>  DataCacheManagerImpl does not suffer from this issue becuase there is only
>  one dataCache.
>  But in the case of a DataCacheManager implementation with multiple named
>  cache - which is what I am implementing now - then this does not work
>  anymore.
>  Moreover, I cannot chnage the behavior of getDataCache(String name) becuase
>  the interface says:
>     /**
>      * Return the named data cache, or null if it does not exist.
>      */
>     public DataCache getDataCache(String name);
>
>
>  Could this code change be made in the future?
>
>  F
>
>



-- 
Patrick Linskey
202 669 5907