company logo

Property :: oldValue - Get value before being modified

The function returns the instance value before modification. The old instance is the instance still being stored in the database. New data set in the instance will be moved to the database when calling save() or changing the selection in the property handle. As long as data is not stored to the database (or transaction), old values can be accessed.

The function should be called for persistent collection properties, only. Calling the function for attributes or transient instances will return a copy of the current value.

Since data for the old instance will be provided on demand, only, one should not preallocate old values, but call the function when required, only.

The function requires that the property handle is positioned. When this is not the case, the function throws an exception.

... fragment ( Property &person ) {

  Value name(person.value("name"));

  if ( person.positioned() ) {

    name = "Miller";

    if ( name != person.oldValue("name") ) // but never name.oldValue()

      Application::output("name changed");

  }

}

Notes:

The function must not be called for newly initializes (and not yet stored) instances, since no old value is available in this case. Moreover, when changing the value several times before storing the instance, the old value will not return the value from the previous change, but the value from the last stored instance, always.

Return value:  Value handle ( odaba::Value  )

A value handle refers to a (usually) opened value. Invalid value handles may cause an exception.

Implementation overview

Implementation details

  1. Provide old value for instance
    odaba::Value Property  :: oldValue (  )

    The function provides a value with the instance data for the old instance.

  2. to list
  3. Provide old value for property
    odaba::Value Property  :: oldValue ( odaba::String &vSimplePath )

    The function provides the old value for the property (attribute) passed in vSimplePath . When the property path is not valid, the function throws an exception.

    • vSimplePath - Simple property path

      A simple property path may contain an extent or property name but also a sequence of property names separated by dot. A simple property path must not contain parenthesis or preceding dots.

  4. to list