Home > Net >  Dynamic table names with JPA
Dynamic table names with JPA

Time:06-13

I have versioned tables like

  1. table_0001
  2. table_0002
  3. table_0003

The tables having the same structure but different data as per version. Version will be received at runtime so could not create entity with table name as it will be dynamic. Is there any way where we can provide some strategy to use same entity and use dynamic table name.

CodePudding user response:

I think it is impossible with jpa because create or update tables at project opening. I suggest Entity-Attribute-Value model for design dynamic table system.

CodePudding user response:

I suggest you read more about @Audited annotation in Hibernate, in reference it is declared as below:

For each audited entity, a table will be created, which will hold the history of changes made to the entity. You can then retrieve and query historical data without much effort.

Here you can read more about it:

https://docs.jboss.org/envers/docs/

  • Related