On Mon, Mar 25, 2024 at 11:35 AM 'Bernd Huber' via jOOQ User Group <
[email protected]> wrote:

> Hello Lukas,
>
> thanks for following up.
>
> exactly like you said, i wrote the own utility because i want to pass the
> following data from the Manager/Services-Layer into the DAO-Layer for each
> "daoFactory.createXyzDao()" call:
> - tenantId
> - langId of the user
> - the dsl of jooq
>

Note that all jOOQ Scope types as well as the Configuration have a generic
Map<Object, Object>, which can be used to pass around such context objects.
Perhaps that would be useful here.


> when i use the DSLContext.transaction() API directly, the could be not as
> slim, i think. See:
>
> ```java
>
> DSLContext ctx = DslContextFactory.createDSLContext(request);
>
> ctx.transaction(trx -> {
>
>     AuthorDao authorDao = daoFactory.createAuthorDao(requestContext, trx)
>
>     trx.dsl().transaction(trx1 -> {
>         // ..
>             BookDao bookDao = daoFactory.createBookDao(requestContext,
> trx1)
>     });
>
> ```
>
> the instantiation of the DSLContext necessarily needs to be given the
> "request" object which contains the "tenantId" and the "langId",
> so it can construct the DSLContext by attaching a custom
> "DefaultExecuteListenerProvider" to the configuration of the DSLContext,
> so all Queries executed by jooq will be appended a "WHERE tenantId = xyz",
> to automatically make sure that a user of tenant=xyz never
> sees or accesses data from an other tenant.
>

How did you implement this from an ExecuteListener? With a regular
expression or VisitListener? Or with the policy feature?
https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/

Though policies are registered separately from an ExecuteListener in the
Configuration...

>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5m%3DoFQ6pA-84V2zjrhP5rO%3DVuZDUtYROY0UKq4L6JQ1A%40mail.gmail.com.

Reply via email to