Reputation: 355
Is it possible to fetch multiple user defined Objects with Jooq. For example can I do something like this?
Factory create = new Factory(connection, SQLDialect.MYSQL);
create.select(AUTHOR,BOOK).from(BOOK).
JOIN(AUTHOR).ON(AUTHOR.AUTHOR_ID.equal(BOOK.AUTHOR_ID)).fetch();
AS we Do,
create.select(AUTHOR.AUTHOR_ID,BOOK.BOOK_ID,BOOK.BOOK_NAME).from(BOOK).
JOIN(AUTHOR).ON(AUTHOR.AUTHOR_ID.equal(BOOK.AUTHOR_ID)).fetch();
Error Message :
Error:(52, 16) java: no suitable method found for select(...)
AUTHOR, BOOK are Tables in Database and JOOQ auto code generator has been used to generate Classes for them.
Any suggestions appreciated :)
Upvotes: 1
Views: 226
Reputation: 221265
You can use Result.into(Table)
for this:
Result<Record> result =
create.select()
.from(BOOK)
.join(AUTHOR).
.on(AUTHOR.AUTHOR_ID.equal(BOOK.AUTHOR_ID))
.fetch();
BookRecord book = result.into(BOOK);
AuthorRecord author = result.into(AUTHOR);
Upvotes: 1