Explanation
In jOOQ 3.6 (when this problem first appears), the DSL.field()
API saw 22 new overloads taking different Row
types as arguments:
- DSL.field(Row1<T1>)
- DSL.field(Row2<T1, T2>)
- DSL.field(Row3<T1, T2, T3>)
- ...
It appears that with this particular API usage above, the new overloads cause a lot of trouble when the javac compiler tries to find the most specific overload among all the possible overloads. The following workaround compiles instantly:
Fix
A fix is under way for releases 3.9.0, 3.8.1, 3.7.4, 3.6.5, removing these methods again from the public API, and providing a renamed substitute that does not cause any overloading issues.
Workarounds
1. Helping the compiler select the most specific DSL.field()
overload
import static org.jooq.impl.DSL.field;
import org.jooq.Field;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
public class Test {
public void method() {
Field<Object> f1 = field("client.id");
Field<Object> f2 = field("client_id");
DSL.using(SQLDialect.MYSQL)
.select()
.where(DSL.trueCondition())
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
;
}
}
2. Preventing target type inference in the context of the and()
method entirely
import static org.jooq.impl.DSL.field;
import org.jooq.Condition;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
public class Test {
public void method() {
Condition condition = field("client.id").eq(field("client_id"));
DSL.using(SQLDialect.MYSQL)
.select()
.where(DSL.trueCondition())
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
;
}
}
More info
This has actually been reported on Stack Overflow before:
- Troubleshoot slow compilation
- http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8086048
And it has been discussed also on the jOOQ user group:
- https://groups.google.com/forum/#!topic/jooq-user/vuaG9d9krDk
- https://groups.google.com/forum/#!topic/jooq-user/grv6Wu_sFtA