java - JPA - Redirect one entity Update/Delete statements to a mirror table -
i working java ee 7 on wildfly server. have strange scenario, client has 2 tables - "employees" , "employees_modified". second table has same structure first 1 , servers modification storage. if employee changes name "john" "john-1", write employees_modified
insert employees_modified(first_name) values("john")
please note other fields in table "employees_modified" empty.
the question is: there way somehow map 2 tables , overwrite values employees in employees_modified present.
i looked @ @inheritance(strategy = inheritancetype.table_per_class) , @attributeoverrides solutions don't seem fit scenario.
look @ hibernate envers, solves problem simply. attach envers project. place first table under audit annotation @audited , @audittable(value = "employees_modified"). pointed @predrag maric important leave other fields of second table empty, can use @postpersist (or listener in pure hibernate) method in entity. in method can describe additional logic employees_modified entity creation , persisting.
Comments
Post a Comment