I add some elements to next collection using set method:
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "CONTRACT_SERVICES", joinColumns = {@JoinColumn(name = "CONTRACT_ID")}, inverseJoinColumns = {@JoinColumn(name = "SERVICE_ID")})
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private List<ContractAddService> addServices = new ArrayList<ContractAddService>(0);
public List<ContractAddService> getAddServices() {
return addServices;
}
public void setAddServices(List<ContractAddService> addServices) {
this.addServices = addServices;
}
after that i change collection content using the same set method:
Contract contract = contractService.get(contractId); | ||||
for (Iterator<Long> iterator = ids.iterator(); iterator.hasNext();) { | ||||
Long addId= iterator.next(); | ||||
ContractAddService service = addService.getSrvsById(addId); | ||||
servList.add(service); | ||||
} | ||||
contract.setAddServices(servList); | ||||
contractService.update(contract); |
Envers logs such change as :
REV | CONTRACT_ID | SERVICE_ID | REVTYPE |
7607 | 395 | 4 | 0 |
7607 | 395 | 5 | 0 |
7607 | 395 | 6 | 0 |
7607 | 395 | 7 | 0 |
7607 | 395 | 8 | 0 |
7607 | 395 | 9 | 0 |
7607 | 395 | 10 | 0 |
7608 | 395 | 3 | 0 |
7608 | 395 | 4 | 0 |
7608 | 395 | 5 | 0 |
7608 | 395 | 6 | 0 |
7608 | 395 | 7 | 0 |
7608 | 395 | 8 | 0 |
7608 | 395 | 9 | 0 |
7608 | 395 | 10 | 0 |
7608 | 395 | 11 | 0 |
7609 | 395 | 3 | 0 |
7609 | 395 | 4 | 0 |
7609 | 395 | 5 | 0 |
7609 | 395 | 8 | 0 |
7609 | 395 | 9 | 0 |
7609 | 395 | 10 | 0 |
7609 | 395 | 11 | 0 |
It looks like all old rows/elements of collection are added again, because they have 0 revtype. Also when quiried with <= envers hql querie deleted entities appears as existing ones because there are no DEL REVTYPE rows created for them.
Is that normal behaviour or envers must process set of collection elements in other way?
Cannot repeat on Envers 4 version