Hello Alf,
about your first question: "what are you gaining by having POJOs in addition to the Record-classes that jOOQ generates?":
i'm using the jooq-codegenerator with following flags:
.withInterfaces(true)
.withPojos(true)
The jooq-codegenerator generated following folders for me that contain the generated code:
- interfaces
- pojos
- records
The "records" folder contains the classes that i use primarily for CRUD-operations on their associated db-tables.
- I can not use the "record"-classes in this folder as frontend-results though.
- they contain jooq-specific code, are not simple pojos and Tools like Swagger also have problem with them as results
The "pojos" folder contains the classes that i can also use as REST-Request and REST-Response data to get and return from/to the frontend (serialized as json)
The classes in the "pojos" folder have no relationship between each other and each pojo is describing the db-table its assoicated with.
When i now take those pojos and add nesting to them i am able to satisfy business use-cases like the following:
- a frontend grid that needs to be remote-paginated and filterable and needs to show data in the grid that consists of data from a db-table but also of data from related tables of this db-table.
for example:
we have a requirement that each Item has language-specific texts in multiple languages (de, fr, it, en, ...)
So there is always a main-table containing data that does not contain language-specific texts, and a directly related table that contains the language-specific texts in the according language.
For example
Table Product (productId, price, stock)
Table ProductLang (productId, langId, name, description)
1 Product has 1-N ProductLang entries associated.
When the user changes the display-language the Grid in the frontend should show the "name", "description" columns in the grid with this display-language.
A different Example would be a "UserModel" where each "User" would have "Roles" associated as well as "Features".
So 1 User would have N Roles and N Features.
It is just convenient to deliver the User-Object to the frontend as a JSON-Object that also contains the Roles and Features of the User.
So to conclude:
- The records do not contain relationships and can not be serialized in a good way to share with the frontend
- The pojos can contain relationships to associated pojos and can be serialized to be shared with the frontend
---------------------------------
MULTISET in the Repository has helped me write a Remote-Pagination Logic in the Backend where the Filters, Sorters on all associated tables
can be given by the frontend to the backend, and the Repository can make Filtering and Sorting possible while also supporting Streaming the Results and Paginating the results.
Im not sure if i understand what you mean by "skipping the repository pattern completely".
---------------------------------
I can understand the wish to drop "maintaining deeply nested business entities and keeping these in sync with the database" alltogether,
if that is possible.
A simplification or removal of business use-cases can help here, to make the app so easy and simple that comlex use-cases are not needed,
but as soon as that seems to be the case, then it may be better to use Tools like "Supabase" or similar things where the Backend is so slim and logic-less,
that its just a passthrough directly to the database.
In my opinion jooq has a very big pro, where such "deeply nested business entities" are necessary and needed,
because there are harder business-use-cases that need backend-logic, backend-scheduling etc.