Unfortunately, there is (currently, as of jOOQ 3.2) no way to typesafely dereference the I
column from your derived table e
, as there is no way the Java compiler can know that there is an I
column. You will have to resort to unsafe methods:
// Enforcing typesafety using coercion:
.join(e)
.on(s.NAME.equal(e.field("I").coerce(String.class))
// Circumventing typesafety using raw types
.join(e)
.on(s.NAME.equal((Field) e.field("I")))
A bit more typesafety can be achieved by reusing the I
field as such:
Source s = SOURCE.as("s");
Field<String> I = SOURCE.ID.as("I");
TableLike<?> e = create.select()
.from(SOURCE)
.where(SOURCE.NAME.isNotNull())
.asTable().as("e");
create.selectCount()
.from(s)
.join(e)
.on(s.NAME.equal(e.field(I)))
.fetchOne().value1();