Hello,

I've stumbled upon LLblgen a couple of times now, I'm sure I'll find
some good inspiration for jOOQ in there. However,

> //Relations to load (customer -> orders -> orderdetails and customer ->
> Address)
> IPrefetchPath prefetchPath = new PrefetchPath();
> prefetchPath.Add(CustomerEntity.PrefetchPathOrders).SubPath.Add(OrderEntity.PrefetchPathOrderDetails);
>
> prefetchPath.Add(CustomerEntity.PrefetchPathAddress);

At first sight, this syntax looks somewhat verbose to me, for the
little features it offers. In fact, it just avoids 1-2 join clauses,
if I understand this correctly? Besides, I'd really prefer not to
expose some implementation internals (the notion of a path that is
"prefetched") in an API. If I'm going to go down that path, I'd really
love the resulting jOOQ code look something like this:

-----------------------------------------------------
// 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"))
-----------------------------------------------------

which would render this SQL

-----------------------------------------------------
-- 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'
-----------------------------------------------------

As indicated in https://github.com/jOOQ/jOOQ/issues/1502. This would
resemble a typesafe HQL

> Because I never trusted this "full OO domain over relational" approach
> advertised by bookwriters and saw a lot of projects where category 2 led to
> disaster, I choose "1" (mybatis) and had success doing so. Now I think that
> Jooq, thanks to its code generation approach does a great job reducing the
> drawbacks of category "1". I am just wondering if it could go even further
> with some common issues such as loading relations.

Yes, it most certainly could.

Reply via email to