14
I am using Hibernate to make the persistence in the database, and in a given case, for each update that a certain entity Consultor
has, it must update in the main table called TB_Consultor
and insert a new row in the table TB_ConsultorHistorico
.
The structure of the tables TB_Consultor
and TB_ConsultorHistorico
are identical and thus
what I’m avoiding is having to map an entity Consultor
and another ConsultorHistorico
that will be identical, and do everything with one entity.
Is it possible to map with Hibernate for the same entity to write to two tables in the database? In one there will be insertions and updates, and in the other, only insertions.
Thank you, I had to make some adaptations with @Attributeoverride because the tables were not 100% equal, because in one the ID was the primary key, and in the other not, but in the end it worked.
– Renato Dinhani