是否可以使用 Jooq 获取多个用户定义的对象。例如,我可以这样做吗?
Factory create = new Factory(connection, SQLDialect.MYSQL);
create.select(AUTHOR,BOOK).from(BOOK).
JOIN(AUTHOR).ON(AUTHOR.AUTHOR_ID.equal(BOOK.AUTHOR_ID)).fetch();
我们这样做,
create.select(AUTHOR.AUTHOR_ID,BOOK.BOOK_ID,BOOK.BOOK_NAME).from(BOOK).
JOIN(AUTHOR).ON(AUTHOR.AUTHOR_ID.equal(BOOK.AUTHOR_ID)).fetch();
错误讯息:
错误:(52,16)java:没有为select(...)找到合适的方法
AUTHOR,BOOK是数据库中的表,JOOQ自动代码生成器已用于为它们生成类。
任何建议表示赞赏:)
答案 0 :(得分:1)
您可以使用Result.into(Table)
:
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);