OFBiz
  1. OFBiz
  2. OFBIZ-4857

Check in GenericEntity.set whether the new value is different from the current one

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: framework
    • Labels:
      None
    • Sprint:
      Bug Crush Event - 21/2/2015

      Description

      In GenericEntity.set(String name, Object value, boolean setIfNull) after the necessary type conversions and checks it should first be verified that the new value is different from the currently set, before the state is set to changed/modified and observers are notified. E.g. (line 432 ff.):

      GenericEntity.java
            Object old = fields.get(name);
                  
            if(!ObjectUtils.equals(old, value)) {
                fields.put(name, value);
                generateHashCode = true;
                modified = true;
                this.setChanged();
                this.notifyObservers(name);
            }
      

      Also the store in the GenericDelegator should be dependant on the modified-flag of the GenericValue to save.
      Update operations could be done more elegantly, and execution time would potentially be saved.

        Activity

        Uwe Allner created issue -
        Uwe Allner made changes -
        Field Original Value New Value
        Description In GenericEntity.set(String name, Object value, boolean setIfNull) after the necessary type conversions and checks it should first be verified that the new value is different from the currently set, before the state is set to changed/modified and observers are notified. E.g. (line 432 ff.):

        {code:title=Bar.java|borderStyle=solid}
              Object old = fields.get(name);
                    
              if(!ObjectUtils.equals(old, value)) {
                  fields.put(name, value);
                  generateHashCode = true;
                  modified = true;
                  this.setChanged();
                  this.notifyObservers(name);
              }
        {code}

        Also the store in the GenericDelegator should be dependant on the modified-flag of the GenericValue to save.
        Update operations could be done more elegantly, and execution time would potentially be saved.
        In GenericEntity.set(String name, Object value, boolean setIfNull) after the necessary type conversions and checks it should first be verified that the new value is different from the currently set, before the state is set to changed/modified and observers are notified. E.g. (line 432 ff.):

        {code:title=GenericEntity.java|borderStyle=solid}
              Object old = fields.get(name);
                    
              if(!ObjectUtils.equals(old, value)) {
                  fields.put(name, value);
                  generateHashCode = true;
                  modified = true;
                  this.setChanged();
                  this.notifyObservers(name);
              }
        {code}

        Also the store in the GenericDelegator should be dependant on the modified-flag of the GenericValue to save.
        Update operations could be done more elegantly, and execution time would potentially be saved.
        Hide
        Jacques Le Roux added a comment -

        Would you suggest a patch?

        Show
        Jacques Le Roux added a comment - Would you suggest a patch?
        Adam Heath made changes -
        Assignee Adam Heath [ doogie ]
        Sharan Foga made changes -
        Sprint Bug Crush Event - 21/2/2015 [ 91 ]
        Sharan Foga made changes -
        Rank Ranked higher
        Sharan Foga made changes -
        Rank Ranked higher
        Sharan Foga made changes -
        Rank Ranked higher

          People

          • Assignee:
            Adam Heath
            Reporter:
            Uwe Allner
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development

                Agile