Hello,
2013/11/10 <[email protected]>
> Hi,
>
> I can write
> Result<BookRecord> bookRecords=jooq.selectFrom(BOOK)
> .where(BOOK.TITLE.eq("Les Misérables"))
> .fetch();
>
> But I can't add a join, I can't write:
> Result<BookRecord> bookRecords=jooq.selectFrom(BOOK)
> .join(AUTHOR).on(BOOK.AUTHOR_ID.eq(AUTHOR.ID))
> .where(AUTHOR.NAME.eq("Victor Hugo"))
> .fetch();
>
> I had to write:
> List<BookRecord> bookRecords=jooq.select(BOOK.fields()).from(BOOK)
> .join(AUTHOR).on(BOOK.AUTHOR_ID.eq(AUTHOR.ID))
> .where(AUTHOR.NAME.eq("Victor Hugo"))
> .fetchInto(BookRecord.class);
>
> Is there an easier way to do the same? How can I tell JOOQ to return
> Result<BookRecord> instead of Result<Record>/List<BookRecord>?
>
Instead of
.fetchInto(BookRecord.class);
You could write
.fetchInto(BOOK);
See:
http://www.jooq.org/javadoc/latest/org/jooq/ResultQuery.html#fetchInto(org.jooq.Table)
You could also write a semi-join using an IN or EXISTS predicate, instead
of joining.
--
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.