【发布时间】:2021-05-19 08:55:39
【问题描述】:
我正在使用 vertx JDBC 客户端池并尝试向表中插入多条记录。插入成功,但插入的记录不返回,只返回第一条记录。
使用batchExecute插入多条记录的代码
List<Tuple> batch = new ArrayList<>();
batch.add(Tuple.of(36,"st","st"));
batch.add(Tuple.of(36,"st1","st1"));
pool.preparedQuery("INSERT INTO table (col1,col2,col3) VALUES($1, $2, $3) returning *").executeBatch(batch,rowSetAsyncResult -> {
System.out.println("size = " + rowSetAsyncResult.result().size()); // this always return 1
for(Row row:rowSetAsyncResult.result()){
System.out.println("id = " + row.getInteger("id"));
}
});
输出
size = 1
id = 87
表格有四列,其中一列是自动递增的,这就是上面代码有 3 列的原因。
我这里有什么遗漏吗?
【问题讨论】:
-
我只是想向 vert.x 报告类似的问题 - 完全异步 pgpool(无 jdbc)似乎也只返回一条记录。
标签: java asynchronous vert.x vertx-verticle vertx-eventbus