在保持类型的同时用条件过滤JOOQ生成的表

时间:2019-03-08 18:51:43

标签: java sql jooq

我已经从数据库中生成了许多JOOQ类。我想按客户轻松过滤表,同时保持表的强类型。

这就是我想要做的:

// Generated class books
JBooks books = JBooks.BOOKS;

// get ownershipCheck (this could be more complicated, possibly joining multiple tables)
Condition ownershipCheck = books.customer().ID.eq(currentCustomer);

// desired output that I can do further operations on
JBooks filteredBooks = selectFrom(books).where(ownershipCheck).asTable();


// a bunch of random operations using the functionality from JBooks
db.select(filteredBooks.AUTHOR, filteredBooks.PUBLISH_DATE, ...etc)

很遗憾,我不能这样做。我得到一个Table<JBooksRecord>,但看不到将新表转换为JBooks

的方法。

0 个答案:

没有答案