Hibernate Envers did not save the initial state of the entity in the history table

151 views Asked by At

The initial state disappears when the username or surname was changed.

Time #1

users table

| id                                   | firstName | lastName |
|--------------------------------------|-----------|----------|
| 4d4d1d28-7bb8-4081-ad46-19821d656643 | John      | Doe      |

history table

| id | version | type | firstName | lastName |
|----|---------|------|-----------|----------|
|    |         |      |           |          |

Time #2

I update the user by REST call and its initial state disappears

curl --location --request PUT 'http://localhost:8080/users/{userId}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "firstName": "Angela",
    "lastName": "Clarkson"
}'

users table

| id                                   | firstName | lastName |
|--------------------------------------|-----------|----------|
| 4d4d1d28-7bb8-4081-ad46-19821d656643 | Angela    | Clarkson |

history table

| id                                   | version | type | firstName | lastName |
|--------------------------------------|---------|------|-----------|----------|
| 4d4d1d28-7bb8-4081-ad46-19821d656643 | 1       | 1    | Angela    | Clarkson |

So we lost the initial state.

How can I solve that?

0

There are 0 answers