Use generator to create same record

25 views
Skip to first unread message

Loris Chiocca

unread,
Jun 7, 2022, 4:55:56 AM6/7/22
to jOOQ User Group
Hi

I've got database that has tables and equivalent views ontop of these tables. The views contain a security layer on the database, but otherwise return the exact same content as the tables. Currently, the generator creates all the objects twice, which is expected. Is there a way to "tweak" the generator to create two table definitions (one for the real table and one for the view) to use the same record?

Thanks
Loris

Lukas Eder

unread,
Jun 7, 2022, 5:12:04 AM6/7/22
to jOOQ User Group
Hi Loris,

Unfortunately, there isn't any such tool. However, you can use generator strategies to let the code generator have the two distinct records extend a common interface:


You could even extend the code generator to generate this interface for you. Or you enable interface generation on all records, and have one record also implement the interface of the other record via a generator strategy.

I hope this helps,
Lukas

--
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 jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/3d1f3cd3-268e-4da9-9e0d-ab3380f41996n%40googlegroups.com.

Christian Meyer

unread,
Jun 10, 2022, 2:38:02 PM6/10/22
to jOOQ User Group
Hey,

Loris, maybe my work will help you: I'm using the generator to build DTOs based on a database tables.
https://github.com/chrisime/crood

Cheers,
Christian
Reply all
Reply to author
Forward
0 new messages