company logo

Instance property nodes

In order to improve performance, the application may refer to internally created access nodes. When creating a property access node, which is used for temporarily storing instance data read from the database, the access node creates access nodes for subordinated properties and values (on demand). Those access nodes are owned by the access node instance and create an implicit access node hierarchy.

There are different ways to refer to instance internal access nodes. The property() function directly returns an internal property handle for a subordinated property. In a similar way, the value() function can be called for providing an internal value access node without creating a copy for the access node.

Property handle and value constructors refer to internal access nodes. In order to create cursor or access handle copies, copyCursor() might be called.

The example below shows, how to refer to internal created access nodes rather than to copies of the access nodes. The method is more efficient, but one has to take into account, that the handle cursor is shared between all (property) handles, that refer to the internal access node.

void OpenHandleHierarchy ( DBObjectHandle &dbo ) {

  Property     person(dbo,"Person::Persons",PI_Read);

  Property    &children = person.property("children");

  Property    &grand_children = children.property("children");

  Value       &name = grandChildren.value("name");

  Value       &firstName = grandChildren.value("first_name");

  

  while ( person.next(true) )

    while ( children.next(true) )

      while ( grandChildren.next(true) )

        printf("Grand child: %s %s",name.toString(),firstName.toString());

}

Notes:

Since this way of accessing properties causes problems in weak-typed collections, we suggest to use standard constructor or open() functions for creating property handles and values. property() and value() functions are intended for being used in short term cases, only.