Issue
context.select(
AUTHOR.FIRST_NAME,
AUTHOR.LAST_NAME,
multiset(
selectDistinct(
BOOK.language().CD,
BOOK.language().DESCRIPTION)
.from(BOOK)
.where(BOOK.AUTHOR_ID.eq(AUTHOR.ID))
).as("books"),
multiset(
selectDistinct(BOOK_TO_BOOK_STORE.BOOK_STORE_NAME)
.from(BOOK_TO_BOOK_STORE)
.where(BOOK_TO_BOOK_STORE.tBook().AUTHOR_ID
.eq(AUTHOR.ID))
).as("book_stores"))
.from(AUTHOR)
.orderBy(AUTHOR.ID)
.fetch();
I was not able to get multiset it. It is throwing the error "Cannot resolve symbol multiset". Which dependencies should I add get get multiset constructor?
Solution
The two most popular explanations for this problem are:
1. You're not using the correct jOOQ version
Since you're using Spring Boot, you might be pulling in jOOQ 3.14 instead of 3.15, when the new MULTISET
operator has been introduced. Spring Boot 2.x won't upgrade to jOOQ versions more recent than 3.14 anymore, because the jOOQ 3.15 Open Source Edition has a JDK baseline of Java 11, and Spring Boot 2.x still requires Java 8 (Spring Boot 3.0 increases its own baselibe to Java 17, fixing this limitation)
But you can easily override the jOOQ dependency introduced by the spring-boot-starter-jooq
as explained in this blog post here. If you're using Maven, just check your dependencies using:
mvn dependency:tree
2. You're missing the usual static imports
All of the jOOQ manual makes the usual assumptions of you declaring a few static imports, including the most important one:
import static org.jooq.impl.DSL.*;
Because multiset()
as documented in the manual is just short for DSL.multiset()
, assuming the above static import. See also this section of the manual.
Answered By - Lukas Eder
Answer Checked By - David Marino (JavaFixing Volunteer)