/** * Return the data cache for this class, or null if it is not cachable. */ public DataCache getDataCache() { String name = getDataCacheName(); if (name == null) { return null; } return _repos.getConfiguration().getDataCacheManagerInstance().getDataCache(name, true); }
/** * Return the data cache for this class, or null if it is not cachable. */ public DataCache getDataCache() { String name = getDataCacheName(); if (name == null) { return null; } return _repos.getConfiguration().getDataCacheManagerInstance().getDataCache(name, true); }
/** * Return the data cache for this class, or null if it is not cachable. */ public DataCache getDataCache() { String name = getDataCacheName(); if (name == null) return null; return _repos.getConfiguration().getDataCacheManagerInstance(). getDataCache(name, true); }
public StoreCache getStoreCache(String cacheName) { return new StoreCacheImpl(this, _factory.getConfiguration(). getDataCacheManagerInstance().getDataCache(cacheName, true)); }
public StoreCache getStoreCache(String cacheName) { return new StoreCacheImpl(this, _factory.getConfiguration(). getDataCacheManagerInstance().getDataCache(cacheName, true)); }
/** * Return the data cache for this class, or null if it is not cachable. */ public DataCache getDataCache() { String name = getDataCacheName(); if (name == null) { return null; } return _repos.getConfiguration().getDataCacheManagerInstance().getDataCache(name, true); }
/** * Return the data cache for this class, or null if it is not cachable. */ public DataCache getDataCache() { String name = getDataCacheName(); if (name == null) { return null; } return _repos.getConfiguration().getDataCacheManagerInstance().getDataCache(name, true); }
public StoreCache getStoreCache(String cacheName) { return new StoreCacheImpl(this, _factory.getConfiguration(). getDataCacheManagerInstance().getDataCache(cacheName, true)); }
public StoreCache getStoreCache(String cacheName) { return new StoreCacheImpl(this, _factory.getConfiguration(). getDataCacheManagerInstance().getDataCache(cacheName, true)); }
public StoreCache getStoreCache(String cacheName) { return new StoreCacheImpl(this, _factory.getConfiguration(). getDataCacheManagerInstance().getDataCache(cacheName, true)); }
@Test public void entity() { final EntityManagerFactory emf = Persistence.createEntityManagerFactory("test-jcache", props); final OpenJPAConfiguration conf = OpenJPAEntityManagerFactorySPI.class.cast(emf).getConfiguration(); final EntityManager em = emf.createEntityManager(); final MyEntity entity = new MyEntity(); entity.setName("cacheMe1"); em.getTransaction().begin(); em.persist(entity); em.getTransaction().commit(); assertNotNull(conf.getDataCacheManagerInstance().getDataCache("default")); assertThat(conf.getDataCacheManagerInstance(), instanceOf(OpenJPAJCacheDataCacheManager.class)); assertThat(conf.getDataCacheManagerInstance().getDataCache("default"), instanceOf(OpenJPAJCacheDataCache.class)); assertTrue(conf.getDataCacheManagerInstance().getDataCache("default").contains(JPAFacadeHelper.toOpenJPAObjectId(conf.getMetaDataRepositoryInstance().getCachedMetaData(MyEntity.class), entity.getId()))); em.close(); emf.close(); }
@Override public void initialize() { Options opts = new Options(); if (getOptions() != null) { opts = Configurations.parseProperties(getOptions()); } String cacheName = opts.getProperty("name",null); OpenJPAConfiguration conf = (OpenJPAConfiguration)getProvider().getConfiguration(); DataCacheManager dcm = conf.getDataCacheManagerInstance(); DataCache dc = null; if (cacheName == null || cacheName.trim().length() == 0) { dc = dcm.getSystemDataCache(); } else { dc = dcm.getDataCache(cacheName); } if (dc == null) { throw new UserException(_loc.get("data-cache-not-found")); } setDataCache(dc); setDataCacheManager(dcm); setConfigId(conf.getId()); setContextRef(Integer.toString(System.identityHashCode(getContext()))); }
@Override public void initialize() { Options opts = new Options(); if (getOptions() != null) { opts = Configurations.parseProperties(getOptions()); } String cacheName = opts.getProperty("name",null); OpenJPAConfiguration conf = (OpenJPAConfiguration)getProvider().getConfiguration(); DataCacheManager dcm = conf.getDataCacheManagerInstance(); DataCache dc = null; if (cacheName == null || cacheName.trim().length() == 0) { dc = dcm.getSystemDataCache(); } else { dc = dcm.getDataCache(cacheName); } if (dc == null) { throw new UserException(_loc.get("data-cache-not-found")); } setDataCache(dc); setDataCacheManager(dcm); setConfigId(conf.getId()); setContextRef(Integer.toString(System.identityHashCode(getContext()))); }
@Override public void initialize() { Options opts = new Options(); if (getOptions() != null) { opts = Configurations.parseProperties(getOptions()); } String cacheName = opts.getProperty("name",null); OpenJPAConfiguration conf = (OpenJPAConfiguration)getProvider().getConfiguration(); DataCacheManager dcm = conf.getDataCacheManagerInstance(); DataCache dc = null; if (cacheName == null || cacheName.trim().length() == 0) { dc = dcm.getSystemDataCache(); } else { dc = dcm.getDataCache(cacheName); } if (dc == null) { throw new UserException(_loc.get("data-cache-not-found")); } setDataCache(dc); setDataCacheManager(dcm); setConfigId(conf.getId()); setContextRef(Integer.toString(System.identityHashCode(getContext()))); }
@Override public void initialize() { Options opts = new Options(); if (getOptions() != null) { opts = Configurations.parseProperties(getOptions()); } String cacheName = opts.getProperty("name",null); OpenJPAConfiguration conf = (OpenJPAConfiguration)getProvider().getConfiguration(); DataCacheManager dcm = conf.getDataCacheManagerInstance(); DataCache dc = null; if (cacheName == null || cacheName.trim().length() == 0) { dc = dcm.getSystemDataCache(); } else { dc = dcm.getDataCache(cacheName); } if (dc == null) { throw new UserException(_loc.get("data-cache-not-found")); } setDataCache(dc); setDataCacheManager(dcm); setConfigId(conf.getId()); setContextRef(Integer.toString(System.identityHashCode(getContext()))); }
@Test public void query() { final EntityManagerFactory emf = Persistence.createEntityManagerFactory("test-jcache", props); final OpenJPAConfiguration conf = OpenJPAEntityManagerFactorySPI.class.cast(emf).getConfiguration(); final EntityManager em = emf.createEntityManager(); final MyEntity entity = new MyEntity(); entity.setName("cacheMe1"); em.getTransaction().begin(); em.persist(entity); em.getTransaction().commit(); final Query query = em.createQuery("select e from OpenJPAJCacheDataCacheTest$MyEntity e where e.id = :id"); assertEquals(1, query.setParameter("id", entity.getId()).getResultList().size()); assertNotNull(conf.getDataCacheManagerInstance().getDataCache("default")); assertThat(conf.getDataCacheManagerInstance(), instanceOf(OpenJPAJCacheDataCacheManager.class)); assertThat(conf.getDataCacheManagerInstance().getDataCache("default"), instanceOf(OpenJPAJCacheDataCache.class)); assertTrue(conf.getDataCacheManagerInstance().getDataCache("default").contains(JPAFacadeHelper.toOpenJPAObjectId(conf.getMetaDataRepositoryInstance().getCachedMetaData(MyEntity.class), entity.getId()))); final Map<Object, Object> args = new HashMap<Object, Object>() {{ put("id", entity.getId()); }}; final QueryKey qk = QueryKey.newInstance(query.unwrap(org.apache.openjpa.kernel.Query.class), args); assertNotNull(conf.getDataCacheManagerInstance().getSystemQueryCache().get(qk)); em.close(); emf.close(); }