I think I may have confused the issue - I have multiple columns in the
subquery to match - so asField() use is out I'm afraid.
here is a better example:
Table<ARecord> a1 = create.select(A.ID, max(A.SOME_DATE).as("max"))
.from(A).groupBy(A.ID).asTable("a1");
create.select(A.fields())
.from(A, a1)
.where(A.ID.eq(a1.field("id")).and(A.SOME_DATE.eq(a1.field("max"))));
So I'm specifically use the table because I need multiple columns returned
to be joined against itself or another table. Even if I only use the a1
object once, don't I need reference to it? Am I using this incorrectly?
What I did discover is that I can abuse the cast() function to get the
correct end result:
create.select(A.fields())
.from(A, a1)
.where(A.ID.eq(cast(a1.field("id"),
Long.class)).and(A.SOME_DATE.eq(cast(a1.field("max"), Timestamp.class))));
The cast didn't even make it into the generated SQL - it was only used to
get jOOQ to understand the types of the fields.
Maybe a field feature could be to cast a type - something like T
field(String name, Class<T> type) just to deal with the generics.
Is there a better solution?
Thanks again.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.