2 Replies Latest reply: Apr 1, 2012 12:32 AM by Adam Warski RSS

how to continue history for a deleted entity ?

mirak1234 Newbie



i have an entity of type A with field

ID wich is the technical id, a generated number

CODE wich is a functional id, it's a string, "foo"

VALUE wich is a value like x


I create A(1,"foo","x")

the entity is saved in the audit table

a new row will appear in A_AUD.


I update A(1,"foo","x") to A(1,"foo","y")

a new row will appear in A_AUD.


now i delete A(1,"foo","y")

the entity will disapear from the main table, and a new row will appear in A_AUD.


now what if i want to create a new revision of A(1,"foo","r") ?


how can i preserve the history ?

I can search for the ID with CODE="foo" in the audit table.

but my guess is that since the row with ID=1 doesn't exist anymore in A, then when i try to insert one, the save from hibernate will automatically generated a new ID, even if i provided one first.


i use sqlserver as database