@Test public void testQueryMultiKeyAllHit() throws Exception { TypeToken<List<Integer>> pt = new TypeToken<List<Integer>>() { }; TypeToken<List<User>> rt = new TypeToken<List<User>>() { }; String srcSql = "select * from user where id in (:1)"; AbstractOperator operator = getOperator(pt, rt, srcSql, new CacheHandlerAdapter() { @Override public Map<String, Object> getBulk(Set<String> keys, Type type, Class<?> daoClass) { Map<String, Object> map = new HashMap<String, Object>(); map.put("user_1", new User()); map.put("user_2", new User()); map.put("user_3", new User()); assertThat(keys, Matchers.equalTo(map.keySet())); return map; } }, new MockCacheBy("")); operator.setJdbcOperations(new JdbcOperationsAdapter()); InvocationStat stat = InvocationStat.create(); operator.execute(new Object[]{Arrays.asList(1, 2, 3)}, stat); assertThat(stat.getHitCount(), equalTo(3L)); assertThat(((CacheableQueryOperator) operator).propertyOfMapperInvoker.getName(), equalTo("id")); }
@Override public Object execute(Object[] values, InvocationStat stat) { InvocationContext context = invocationContextFactory.newInvocationContext(values); return driver.isUseMultipleKeys() ? multipleKeysCache(context, rowMapper.getMappedClass(), driver.getOnlyCacheByClass(), stat) : singleKeyCache(context, stat); }
CacheableQueryOperator extends QueryOperator { @Override public Object execute(Object[] values, InvocationStat stat) { InvocationContext context = invocationContextFactory.newInvocationContext(values); return driver.isUseMultipleKeys() ? multipleKeysCache(context, rowMapper.getMappedClass(), driver.getOnlyCacheByClass(), stat) : singleKeyCache(context, stat); } }
CacheableQueryOperator extends QueryOperator { @Override public Object execute(Object[] values, InvocationStat stat) { InvocationContext context = invocationContextFactory.newInvocationContext(values); return driver.isUseMultipleKeys() ? multipleKeysCache(context, rowMapper.getMappedClass(), driver.getOnlyCacheByClass(), stat) : singleKeyCache(context, stat); } CacheableQueryOperator(ASTRootNode rootNode, MethodDescriptor md, CacheDriver cacheDriver, Config config); }
CacheableQueryOperator extends QueryOperator { @Override public Object execute(Object[] values, InvocationStat stat) { InvocationContext context = invocationContextFactory.newInvocationContext(values); return driver.isUseMultipleKeys() ? multipleKeysCache(context, rowMapper.getMappedClass(), driver.getOnlyCacheByClass(), stat) : singleKeyCache(context, stat); } CacheableQueryOperator(ASTRootNode rootNode, MethodDescriptor md, CacheDriver cacheDriver, Config config); @Override Object execute(Object[] values, InvocationStat stat); }
CacheableQueryOperator extends QueryOperator { @Override public Object execute(Object[] values, InvocationStat stat) { InvocationContext context = invocationContextFactory.newInvocationContext(values); return driver.isUseMultipleKeys() ? multipleKeysCache(context, rowMapper.getMappedClass(), driver.getOnlyCacheByClass(), stat) : singleKeyCache(context, stat); } CacheableQueryOperator(ASTRootNode rootNode, MethodDescriptor md, CacheDriver cacheDriver, Config config); @Override Object execute(Object[] values, InvocationStat stat);  }