Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add support for implicit join over to-one relationships #1502
It would be nice if jOOQ could detect necesary JOINs automatically using a syntax such as:
// Query 1 create.select(FIRST_NAME, LAST_NAME) .from(AUTHORS) .where(AUTHORS.BOOKS().TITLE.equal("1984")) // Query 2 create.select(TITLE) .from(BOOKS) .where(BOOKS.AUTHORS().LAST_NAME.equal("Orwell"))
This is the SQL that would be generated:
-- Query 1 SELECT first_name, last_name FROM authors WHERE EXISTS ( SELECT 1 FROM books WHERE books.author_id = author.id AND books.title = '1984' ) -- Query 2 SELECT title FROM books JOIN authors ON authors.id = books.author_id WHERE authors.last_name = 'Orwell'
This issue will cover the "to-one" part of implicit joins, whose implementation is straightforward. Work in progress:
Findings from an initial implementation:
As it looks right now, we might not implement this feature in jOOQ, unless we find a way to significantly speed up solution 2), or we find another solution 3) that is not yet exposed here.