@Test public void testExecuteReturnVoid() throws Exception { TypeToken<List<User>> pt = new TypeToken<List<User>>() { }; TypeToken<Void> rt = TypeToken.of(void.class); String srcSql = "update user set name=:1.name where id=:1.id"; AbstractOperator operator = getOperator(pt, rt, srcSql); final int[] expectedInts = new int[]{1, 2}; operator.setJdbcOperations(new JdbcOperationsAdapter() { @Override public int[] batchUpdate(DataSource ds, List<BoundSql> boundSqls) { String sql = boundSqls.get(0).getSql(); String descSql = "update user set name=? where id=?"; assertThat(sql, equalTo(descSql)); assertThat(boundSqls.size(), equalTo(2)); assertThat(boundSqls.get(0).getArgs().get(0), equalTo((Object) "ash")); assertThat(boundSqls.get(0).getArgs().get(1), equalTo((Object) 100)); assertThat(boundSqls.get(1).getArgs().get(0), equalTo((Object) "lucy")); assertThat(boundSqls.get(1).getArgs().get(1), equalTo((Object) 200)); return expectedInts; } }); List<User> users = Arrays.asList(new User(100, "ash"), new User(200, "lucy")); Object actual = operator.execute(new Object[]{users}, InvocationStat.create()); assertThat(actual, nullValue()); }
@Override public Object execute(Object[] values, InvocationStat stat) { Iterables iterables = getIterables(values); if (iterables.isEmpty()) { return transformer.transform(new int[]{}); } Map<DataSource, Group> gorupMap = new HashMap<DataSource, Group>(); int t = 0; for (Object obj : iterables) { InvocationContext context = invocationContextFactory.newInvocationContext(new Object[]{obj}); group(context, gorupMap, t++); } int[] ints = executeDb(gorupMap, t, stat); return transformer.transform(ints); }
BatchUpdateOperator extends AbstractOperator { @Override public Object execute(Object[] values, InvocationStat stat) { Iterables iterables = getIterables(values); if (iterables.isEmpty()) { return transformer.transform(new int[]{}); } Map<DataSource, Group> gorupMap = new HashMap<DataSource, Group>(); int t = 0; for (Object obj : iterables) { InvocationContext context = invocationContextFactory.newInvocationContext(new Object[]{obj}); group(context, gorupMap, t++); } int[] ints = executeDb(gorupMap, t, stat); return transformer.transform(ints); } }
BatchUpdateOperator extends AbstractOperator { @Override public Object execute(Object[] values, InvocationStat stat) { Iterables iterables = getIterables(values); if (iterables.isEmpty()) { return transformer.transform(new int[]{}); } Map<DataSource, Group> gorupMap = new HashMap<DataSource, Group>(); int t = 0; for (Object obj : iterables) { InvocationContext context = invocationContextFactory.newInvocationContext(new Object[]{obj}); group(context, gorupMap, t++); } int[] ints = executeDb(gorupMap, t, stat); return transformer.transform(ints); } BatchUpdateOperator(ASTRootNode rootNode, MethodDescriptor md, Config config); }
BatchUpdateOperator extends AbstractOperator { @Override public Object execute(Object[] values, InvocationStat stat) { Iterables iterables = getIterables(values); if (iterables.isEmpty()) { return transformer.transform(new int[]{}); } Map<DataSource, Group> gorupMap = new HashMap<DataSource, Group>(); int t = 0; for (Object obj : iterables) { InvocationContext context = invocationContextFactory.newInvocationContext(new Object[]{obj}); group(context, gorupMap, t++); } int[] ints = executeDb(gorupMap, t, stat); return transformer.transform(ints); } BatchUpdateOperator(ASTRootNode rootNode, MethodDescriptor md, Config config); @Override Object execute(Object[] values, InvocationStat stat); }
BatchUpdateOperator extends AbstractOperator { @Override public Object execute(Object[] values, InvocationStat stat) { Iterables iterables = getIterables(values); if (iterables.isEmpty()) { return transformer.transform(new int[]{}); } Map<DataSource, Group> gorupMap = new HashMap<DataSource, Group>(); int t = 0; for (Object obj : iterables) { InvocationContext context = invocationContextFactory.newInvocationContext(new Object[]{obj}); group(context, gorupMap, t++); } int[] ints = executeDb(gorupMap, t, stat); return transformer.transform(ints); } BatchUpdateOperator(ASTRootNode rootNode, MethodDescriptor md, Config config); @Override Object execute(Object[] values, InvocationStat stat);  }