1
submitted 1 year ago* (last edited 1 year ago) by BBloggsbott@beehaw.org to c/programming@beehaw.org

I have multiple tables with the same schema. The only difference is the table name. Table names are in the format table_name_<tenant_id>, for example, table_name_1, table_name_24, table_name_15 etc.,

I want to use a single Entity and JPA repository to perform operations on this table. I get the tenant_id from the Request. I want to execute queries on the corresponding tables.

How do I dynamically set the table name to be used for querying?

We have only 5 such tables since the data for each tenant is very high

Not adding a MWE since I couldn't find any place to start trying approaches.

Edit: Replace user_id with tenant_id and add number of tables present

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here
this post was submitted on 04 Jul 2023
1 points (100.0% liked)

Programming

13360 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS