1

Using Javers for the fetching historical data (Audit purpose) in Java Springboot. I have a entity which is having one to many relationship with other child entities. Below is the example what we are doing. Example :

@Entity
@Getter
@Setter
@NoArgsConstructor
class ParentEntity{

@Id
@GenericGenerator(name = "UUIDGenerator", strategy = "uuid2")
@GeneratedValue(generator = "UUIDGenerator")
@Column(name = "id", updatable = false, nullable = false)
private UUID id;

@Column(name = "customer_id")
private String customerId;


@OneToMany(mappedBy = "parentEntity", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ChildEntity> childEntity;

} 
@Entity
@Getter
@Setter
class ChildEntity{

@Id
@GenericGenerator(name = "UUIDGenerator", strategy = "uuid2")
@GeneratedValue(generator = "UUIDGenerator")
@Column(name = "id", updatable = false, nullable = false)
protected UUID id;

@ManyToOne(fetch = FetchType.LAZY)
private ParentEntity parentEntity;

}

If I made a change for the object of Child entity which is present in Parent, we are getting the ListChange object but it does not contains the actual object changed, it is having the reference global id inside it.

We are using below query :

javers.findChanges(QueryBuilder.byInstanceId(id, classname).withSnapshotTypeUpdate().build());

Is there any way to fetch the exact object values from the Javers tables?

I am getting the response which has the global id for respective updated object in Left and Right.

I am looking for the objects which got changed (Previous version and updated version)

Andrej Istomin
  • 2,527
  • 2
  • 15
  • 22

0 Answers0