jOOQ / jOOQ

jOOQ is the best way to write SQL in Java
https://www.jooq.org
Other
6.09k stars 1.2k forks source link

Fix known limitations of embeddable types #15892

Open lukaseder opened 9 months ago

lukaseder commented 9 months ago

This is a continuation of #8353, #10527, and #11975, which fixed a lot of issues already in jOOQ 3.14 / 3.15 / 3.19

Runtime library (known issues)

Runtime library (not integration tested yet)

Code generator (known issues)

Code generator (not integration tested yet)

alf commented 3 months ago

Is it possible to find the parent table of an embedded primary key given just the embedded record?

lukaseder commented 3 months ago

@alf Embedded keys are just a code generation convenience feature, where the code generator makes sure that primary/unique constraints will generate the same embeddable type as the referencing foreign keys. There's no runtime information generated about the types being derived from keys.

You can, of course, query the generated code using Java reflection to find out who references an embedded type, and then implement heuristics, knowing your own code generation configuration.

I guess it could make sense, in some cases, to maintain meta information about this relationship. If you're interested in that, could you please create a new feature request with details about your use-case?

alf commented 3 months ago

Created feature request: https://github.com/jOOQ/jOOQ/issues/16803