1 Reply Latest reply: May 8, 2012 4:49 AM by Vyacheslav Sakhno RSS

    Bug in collection audit processing:

    Vyacheslav Sakhno Newbie

      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 :

       

       

      REVCONTRACT_IDSERVICE_IDREVTYPE
      760739540
      760739550
      760739560
      760739570
      760739580
      760739590
      7607395100
      760839530
      760839540
      760839550
      760839560
      760839570
      760839580
      760839590
      7608395100
      7608395110
      760939530
      760939540
      760939550
      760939580
      760939590
      7609395100
      7609395110

       

      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?