Result adapter

JsonRecord

Vertx JsonObject vs jOOQ Record…​

Ya, merging: JsonRecord

final io.github.zero88.sample.model.pgsql.tables.Authors table = Tables.AUTHORS;
jooqx.fetchJsonRecord(dsl -> dsl.selectFrom(table).where(table.NAME.eq("zero88")).limit(1)) (1)
     .onSuccess(r -> {
         JsonRecord<AuthorsRecord> record = r;                                  (2)
         assert Objects.equals(record.toJson().encode(), """
             {"id": 8, "name": "zero88", "country": "VN"}
             """);                                                              (3)

         assert Objects.equals(record.toString(), """
             +----+-------+-------+
             |  id|name   |country|
             +----+-------+-------+
             |  *8|*zero88|*VN    |
             +----+-------+-------+
             """);                                                              (4)
     }).onFailure(Throwable::printStackTrace);
1 Execute query
2 Access Json record object seamlessly without cast type
3 output: {"id":88,"name":"zero88","country":"VN"}

By class

jooqx.execute(dsl -> dsl.selectFrom(Tables.AUTHORS),
              DSLAdapter.fetchMany(Tables.AUTHORS, Authors.class))              (1)
     .onSuccess(authors -> {
         Authors author = authors.get(0);                                       (2)
         assert author.getId() == 1;                                            (3)
         assert Objects.equals(author.getCountry(), "UK");                  (4)
     }).onFailure(Throwable::printStackTrace);

By Fields

final Books t = Tables.BOOKS;
jooqx.execute(dsl -> dsl.insertInto(t, t.TITLE).values("aha").returning(), DSLAdapter.fetchOne(t.ID),   (1)
              ar -> {
                  Record record = ar.result();
                  assert record.get(t.ID) == 10;                                (2)
                  assert (Integer) record.getValue(0) == 10;            (3)
              });