public boolean contains(Object oid) { if (_cache == null) return false; try { return _cache.contains(oid); } catch (RuntimeException re) { throw translate(re); } }
public boolean contains(Object oid) { if (_cache == null) return false; try { return _cache.contains(oid); } catch (RuntimeException re) { throw translate(re); } }
public boolean contains(Object oid) { if (_cache == null) return false; try { return _cache.contains(oid); } catch (RuntimeException re) { throw translate(re); } }
public boolean contains(Object oid) { if (_cache == null) return false; try { return _cache.contains(oid); } catch (RuntimeException re) { throw translate(re); } }
public boolean contains(Object oid) { if (_cache == null) return false; try { return _cache.contains(oid); } catch (RuntimeException re) { throw translate(re); } }
public boolean isCached(List<Object> oids, BitSet edata) { // If using partitioned cache, we were and still are broke. DataCache cache = _mgr.getSystemDataCache(); if (cache != null && !isLocking(null)) { // BitSet size is not consistent. for(int i = 0; i < oids.size(); i++) { Object oid = oids.get(i); // Only check the cache if we haven't found the current oid. if (edata.get(i) == false && cache.contains(oid)) { edata.set(i); } } if (edata.cardinality() == oids.size()){ return true; } } return super.isCached(oids, edata); }
public boolean isCached(List<Object> oids, BitSet edata) { // If using partitioned cache, we were and still are broke. DataCache cache = _mgr.getSystemDataCache(); if (cache != null && !isLocking(null)) { // BitSet size is not consistent. for(int i = 0; i < oids.size(); i++) { Object oid = oids.get(i); // Only check the cache if we haven't found the current oid. if (edata.get(i) == false && cache.contains(oid)) { edata.set(i); } } if (edata.cardinality() == oids.size()){ return true; } } return super.isCached(oids, edata); }
public boolean isCached(List<Object> oids, BitSet edata) { // If using partitioned cache, we were and still are broke. DataCache cache = _mgr.getSystemDataCache(); if (cache != null && !isLocking(null)) { // BitSet size is not consistent. for(int i = 0; i < oids.size(); i++) { Object oid = oids.get(i); // Only check the cache if we haven't found the current oid. if (edata.get(i) == false && cache.contains(oid)) { edata.set(i); } } if (edata.cardinality() == oids.size()){ return true; } } return super.isCached(oids, edata); }
public boolean isCached(List<Object> oids, BitSet edata) { // If using partitioned cache, we were and still are broke. DataCache cache = _mgr.getSystemDataCache(); if (cache != null && !isLocking(null)) { // BitSet size is not consistent. for(int i = 0; i < oids.size(); i++) { Object oid = oids.get(i); // Only check the cache if we haven't found the current oid. if (edata.get(i) == false && cache.contains(oid)) { edata.set(i); } } if (edata.cardinality() == oids.size()){ return true; } } return super.isCached(oids, edata); }
public boolean exists(OpenJPAStateManager sm, Object edata) { DataCache cache = sm.getMetaData().getDataCache(); if (cache != null && !isLocking(null) && cache.contains(sm.getObjectId())) return true; return super.exists(sm, edata); }
} else if (!cache.contains(sm.getObjectId())) unloaded = addUnloaded(sm, null, unloaded);
@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(); }
@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(); }
} else if (!cache.contains(sm.getObjectId())) unloaded = addUnloaded(sm, null, unloaded);
public boolean exists(OpenJPAStateManager sm, Object edata) { DataCache cache = _mgr.selectCache(sm); CacheStatistics stats = (cache == null) ? null : cache.getStatistics(); if (cache != null && !isLocking(null) && cache.contains(sm.getObjectId())){ if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return true; } // If isLocking(null)==true && cache.contains(..) == true... probably shouldn't count? if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return super.exists(sm, edata); }
} else if (!cache.contains(sm.getObjectId())) unloaded = addUnloaded(sm, null, unloaded);
} else if (!cache.contains(sm.getObjectId())) unloaded = addUnloaded(sm, null, unloaded);
public boolean exists(OpenJPAStateManager sm, Object edata) { DataCache cache = _mgr.selectCache(sm); CacheStatistics stats = (cache == null) ? null : cache.getStatistics(); if (cache != null && !isLocking(null) && cache.contains(sm.getObjectId())){ if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return true; } // If isLocking(null)==true && cache.contains(..) == true... probably shouldn't count? if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return super.exists(sm, edata); }
public boolean exists(OpenJPAStateManager sm, Object edata) { DataCache cache = _mgr.selectCache(sm); CacheStatistics stats = (cache == null) ? null : cache.getStatistics(); if (cache != null && !isLocking(null) && cache.contains(sm.getObjectId())){ if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return true; } // If isLocking(null)==true && cache.contains(..) == true... probably shouldn't count? if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return super.exists(sm, edata); }
public boolean exists(OpenJPAStateManager sm, Object edata) { DataCache cache = _mgr.selectCache(sm); CacheStatistics stats = (cache == null) ? null : cache.getStatistics(); if (cache != null && !isLocking(null) && cache.contains(sm.getObjectId())){ if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return true; } // If isLocking(null)==true && cache.contains(..) == true... probably shouldn't count? if (stats != null && stats.isEnabled()) { // delay this call ONLY if stats collection is enabled Class<?> cls = sm.getMetaData().getDescribedType(); ((CacheStatisticsSPI)stats).newGet(cls, false); } return super.exists(sm, edata); }