> I'm currently undecided about how to further evolve these into()
> methods. While I would imagine that mapping an annotated (or
> non-annotated) @OneToOne or @ManyToOne relationship is rather simple,
> I guess it would get more tricky for @OneToMany or @ManyToMany.
Some considerations about the mapping (Here, jOOQ should behave as a
partial JPA implementation):
1. Adding support for these annotations may indicate to some that lazy
fetching is possible with jOOQ. This will not be true. Fetching is
done in jOOQ, the mapping is done based on what is available in a flat
org.jooq.Result. This feature limitation must not be forgotten when
designing such extensions.
2. The fact that you join TABLE, OTHER, CHILD and the fact that you
have Table with Other and List<Child> attributes is a coincidence. JPA
has a "model-first strategy" and renders the necessary SQL depending
on what outcome you want (Table, Other, List<Child> generate the
required JPQL / SQL). With jOOQ, the inverse would be true. The SQL
generates a flat table and results will somehow have to be mapped
according to what is available through reflection. Having a
List<Child> attribute means that automatically, the resulting table
will be "grouped" by CHILD.TABLE_ID, returning only unique Table
values. This opens a lot of questions for transitivity. E.g. what if
Other has a List<Table> attribute? What if Table has a List<Table>
attribute?
3. @JoinColumn will probably be a necessary annotation as well
4. Is there any potential for a partial solution not involving JPA
annotations? Simple mappings could be handled, in principle. Should
jOOQ go down that path?
Some considerations about the code-generator:
1. Should jooq-codegen be adapted in order to generate @OneToMany and
@ManyToOne annotations automatically for generated pojos?
2. Can @OneToOne and @ManyToMany relations even be discovered automatically?
3. How would code-generation impact generated interfaces and/or
generated records?
4. How would code-generation impact generated DAOs?
Cheers
Lukas