Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using QueryExecutor for Nested data structures #214

Open
ivanovdns opened this issue Nov 6, 2022 · 1 comment
Open

Using QueryExecutor for Nested data structures #214

ivanovdns opened this issue Nov 6, 2022 · 1 comment

Comments

@ivanovdns
Copy link

Hello!
I need some assistance in fetching nested data structures by jooq.
JOOQ provides dsl:

record Name(String firstName, String lastName) {}
record Book(int id, String title) {}
record Author(int id, Name name, List<Book> books) {} // Is now using a List<Book> instead of Book[]

// Again, no structural typing here has gone!
List<Author> authors =
create.select(
         AUTHOR.ID,
         row(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME).mapping(Name::new),
         array(
           select(row(BOOK.ID, BOOK.TITLE).mapping(Book.class, Book::new)
           .from(BOOK)
           .where(BOOK.AUTHOR_ID.eq(AUTHOR.ID))
         ).convertFrom(Arrays::asList) // Additional converter here
       )
      .from(AUTHOR)
      .fetch(Records.mapping(Author::new));

Is it possible to use this API in conjunction with vertx and vertx-jooq libraries?

@jklingsporn
Copy link
Owner

Sorry for the late response. That should work when using a jdbc-module with an instance of io.github.jklingsporn.vertx.jooq.shared.internal.jdbc.JDBCQueryExecutor. When you want to go reactive, I'm afraid we're limited to the mapping capabilities of the reactive pg client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants