1

I'm trying to generate multiple tables out of a Java entity, the problem is that I need to generate them dynamically. Tables are numbered as table_tenantId

So, if I have multiple tenants I need to have a table per tenant. So If I have 3 tenants on my application I'll have:

table_1
table_2
table_3

But if I have 4 tenants, I'll need to have:

table_4

I've seen the answer stated here JPA, How to use the same class (entity) to map different tables?

But I need to generate the class by myself.

Is there a way I can generate them dynamically?

////////////// Update //////////////

Columns:

private Long id;

private String filing_date; 

private String index_date;

private String filing_id_number;

private Byte state;

private Long documentalTypeInstance_id;

private Long documentalstructureinstance_id;

private Long parent_id;

private Long physicallocation_id;

private Long user_id;

private Long formdocument_id;

private String token_id;

private Boolean is_loaned;    

Thanks!

5
  • Are you sure it is good idea? Like for me, it is more correct to have single table tenant with foreign key to person (1,2,3 etc) instead of having multiple tables for each one. Commented May 31, 2019 at 16:31
  • Could you provide column names of your tables, so we could try to help you. Commented May 31, 2019 at 16:33
  • I just added the column Names, thanks Commented May 31, 2019 at 16:40
  • @BorLaze It's because per tenant that table has millions of rows, and if every tenant is on the same table It can lead to a pretty bad performance issues Commented May 31, 2019 at 16:48
  • baeldung.com/hibernate-5-multitenancy Commented Jun 1, 2019 at 8:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.