New replacers functionality

13 views
Skip to first unread message

Jason Bennett

unread,
Apr 11, 2024, 4:37:40 PMApr 11
to jOOQ User Group
I have a use case where I have a certain table that is manually sharded, such that each customer account has their own copy of the table, but the schema are identical (e.g. customer_data_1, customer_data_2). In the past, it appears that static table mapping was the answer, although I don't think that actually addresses my problem.

I see there is new functionality called Replacers that seems to do exactly what I want, but is commercial-only apparently. Is there similar functionality in the open-source version, or just this new feature in commercial?

Lukas Eder

unread,
Apr 12, 2024, 4:51:29 AMApr 12
to jooq...@googlegroups.com
Hi Jason,

Unless you have complex, per-query naming logic for those tables (in case of which Replacers would be a good approach), I think that your use-case is still sufficiently covered by the runtime schema/table mapping feature?

Why do you think it doesn't address your problem?

Lukas

On Thu, Apr 11, 2024 at 10:37 PM Jason Bennett <jas...@gmail.com> wrote:
I have a use case where I have a certain table that is manually sharded, such that each customer account has their own copy of the table, but the schema are identical (e.g. customer_data_1, customer_data_2). In the past, it appears that static table mapping was the answer, although I don't think that actually addresses my problem.

I see there is new functionality called Replacers that seems to do exactly what I want, but is commercial-only apparently. Is there similar functionality in the open-source version, or just this new feature in commercial?

--
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/29ffddf7-bd3c-490b-a82d-2f9abbd6c484n%40googlegroups.com.

Jason Bennett

unread,
Apr 12, 2024, 12:58:54 PMApr 12
to jOOQ User Group
(sorry if this gets duplicated)

I guess I'm just not clear how I would do a one to many mapping in this situation. If I have customer 13 come in, and I need to query his table, I'm unclear how I can take the "standard" schema, and then say "for this particular query, use this schema against table customer_data_13."

Jason Bennett

unread,
Apr 12, 2024, 7:12:18 PMApr 12
to jOOQ User Group
So, it appears that all I really need is the rename() function, but I was surprised at the naming - I expected that function to actually rename a table with DDL! I see that is actually under the ALTER section.

Lukas Eder

unread,
Apr 13, 2024, 4:25:42 AMApr 13
to jooq...@googlegroups.com
My suggestion is to generate your schema from the "base schema" in your dev environment, for example, to get a CUSTOMER table. And then, for customer 13, configure a Configuration / Settings that rewrites all references to CUSTOMER to CUSTOMER_DATA_13.

Obviously, you can rename tables on a per-query basis, but then you'll keep forgetting this for 1-2 queries, and it will be scattered across your code.

Let me know if anything's unclear in the documentation:


Jason Bennett

unread,
Apr 16, 2024, 12:59:23 PMApr 16
to jooq...@googlegroups.com
I guess I'm just not clear how I would do a one to many mapping in this situation. If I have customer 13 come in, and I need to query his table, I'm unclear how I can take the "standard" schema, and then say "for this particular query, use this schema against table customer_data_13."

You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/6hDnJUynq0I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5wD3suigBOeaWNfCJVW9h_fYf6XyCpA%3DAbA4ZX1inA7g%40mail.gmail.com.


--
Jason Bennett, jas...@acm.org
E pur si muove!

Reply all
Reply to author
Forward
0 new messages