Re: Any way to check if object has really changed?

From: Bryan Lewis (jbryanlewi..mail.com)
Date: Tue Mar 24 2009 - 11:16:33 EDT

  • Next message: John Armstrong: "Internal row comparison in ExpressionFactory"

    Yep, we've been using essentially the same code to detect real changes to
    objects so that we can keep an audit trail of all changes. However, we did
    run into one little special case.

    If the object has a to-one relationship that's toDependentPK, and it happens
    to have a null current value, it will always appear to have changed. The
    old value always appears to be non-null because the dbAttribute is the
    source object's primary key. We had to modify the last 'if' statement from:

        if (!Util.nullSafeEquals(dbval, objval))

    to:

        if (!Util.nullSafeEquals(dbval, objval)
           && !(DataObjectUtils.pkForObject(p) == null &&
    dbr.isToDependentPK()))

    This causes us to miss removals (nullifying) of such a relationship but
    that's a rare occurrence. Would be glad to hear a better way.



    This archive was generated by hypermail 2.0.0 : Tue Mar 24 2009 - 11:17:06 EDT