@Test public void testClear() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); LruObjectCache cache = new LruObjectCache(2); dao.setObjectCache(cache); Foo foo = new Foo(); int val = 12312321; foo.val = val; assertEquals(1, dao.create(foo)); assertEquals(1, cache.size(Foo.class)); Foo result = dao.queryForId(foo.id); assertSame(foo, result); dao.clearObjectCache(); result = dao.queryForId(foo.id); assertNotSame(foo, result); }
@Override public <T> void clear(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap != null) { objectMap.clear(); } }
LruObjectCache implements ObjectCache { @Override public <T> void clear(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap != null) { objectMap.clear(); } } }
LruObjectCache implements ObjectCache { @Override public <T> void clear(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap != null) { objectMap.clear(); } } LruObjectCache(int capacity); }
LruObjectCache implements ObjectCache { @Override public <T> void clear(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap != null) { objectMap.clear(); } } LruObjectCache(int capacity); @Override synchronized void registerClass(Class<T> clazz); @Override T get(Class<T> clazz, ID id); @Override void put(Class<T> clazz, ID id, T data); @Override void clear(Class<T> clazz); @Override void clearAll(); @Override void remove(Class<T> clazz, ID id); @Override T updateId(Class<T> clazz, ID oldId, ID newId); @Override int size(Class<T> clazz); @Override int sizeAll(); }
LruObjectCache implements ObjectCache { @Override public <T> void clear(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap != null) { objectMap.clear(); } } LruObjectCache(int capacity); @Override synchronized void registerClass(Class<T> clazz); @Override T get(Class<T> clazz, ID id); @Override void put(Class<T> clazz, ID id, T data); @Override void clear(Class<T> clazz); @Override void clearAll(); @Override void remove(Class<T> clazz, ID id); @Override T updateId(Class<T> clazz, ID oldId, ID newId); @Override int size(Class<T> clazz); @Override int sizeAll();  }