在https://quarkus.io/guides/reactive-sql-clients页面中,我们有代码片段来使用事务执行查询更改:
SqlClientHelper.inTransactionUni(client, tx -> tx
.preparedQuery("INSERT INTO person (firstname,lastname) VALUES ($1,$2) RETURNING id").execute(Tuple.of(person.getFirstName(), person.getLastName()))
.onItem().transformToUni(id -> tx.preparedQuery("INSERT INTO addr (person_id,addrline1) VALUES ($1,$2)")
.execute(Tuple.of(id.iterator().next().getLong("id"), person.getLastName()))).onItem().ignore().andContinueWithNull());
所以这里 SqlClientHelper 将开始事务,如果任何失败,提交和回滚,但是有没有办法找出失败的根本原因并将其打印在日志中?在文档中没有提到我们如何做到这一点。