object-domain-iconDBAccess supports managed objects based on their domain membership.  A domain is represented by a string and can be any valid string and there are no limits to how many can be created.

By default, objects are not managed unless specifically set to be.


This can be done in the following ways:

  • Via DBAccess settings, where defaultManagedObjects is set to YES.  Then all objects that are retrieved from or committed to the datastore are registered within the default domain (“dbaccess.default”).
  • Manually specifying the domain using the setManagedObjectDomain method on individual objects.
  • Or when performing a query by specifying domain: in the query setup, then all objects in the DBResultSet are members of that domain.

Sibling objects are only updated when committals or removals are performed, this is to avoid unnecessary “chatter” between all the siblings, just because you have set a property (which ultimately may get rolled back by the database).

Examples of how managed objects may be used:

Person* p1 = [Person new];
[p1 setManagedObjectDomain:@"dbaccess.domain"];
[p1 commit];
Person* p2 = [[[[Person query] domain:@"dbaccess.domain"] fetch] firstObject];
[p2 setManagedObjectDomain:@"dbaccess.domain"];
Person* p3 = [[[Person query] fetch] firstObject];
[p3 setManagedObjectDomain:@"different.domain"]; = @"Adrian Herridge";
// p2 still retains it's original value for name.
[p1 commit]
// p2 has now been updated to reflect the committal of p1's name property
// to the database.
// p3 however remains the same, as it is a member of a different domain.