I've got the following setup:
@Entity
@Audited
public class House {
@OneToOne(cascade = CascadeType.ALL)
private Door frontDoor;
// ...
}
@Entity
@Audited
public class Door {
private String color;
// ...
}
and then somewhere else in my code the following lines:
// #1: Creation of house
var house = new House();
var door = new Door();
door.setColor("red");
house.setFrontDoor(door);
houseRepository.save(door);
// #2: Modification of the front door
// (in another method)
var house = houseRepository.getById(/*...*/);
var door = house.getDoor();
door.setColor("blue");
houseRepository.save(house);
So what I get in my audit tables is something like this:
DOOR_AUD:
ID | COLOR | REV | REVTYPE |
---|---|---|---|
1 | red | 1 | 0 |
1 | blue | 2 | 1 |
HOUSE_AUD:
ID | FRONT_DOOR | REV | REVTYPE |
---|---|---|---|
2 | 1 | 1 | 0 |
However I need to get a new entry in HOUSE_AUD
as well
(like if I would modify a direct/primitive property in house
):
ID | FRONT_DOOR | REV | REVTYPE |
---|---|---|---|
2 | 1 | 1 | 0 |
2 | 1 | 2 | 1 |
Is there any way to tell Envers to create a new Revision for all affected parents?