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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -