Cascade Operations

Composite relationships are cascaded. Cascade operations allow a single synchronization to execute a chain of related CUD operations. Multi-level insert is a special case for cascade operations. Multilevel insert allows a single synchronization to execute a chain of related insert operations, creating parent and children objects.

Multilevel Insert

This example demonstrates a multilevel insert:

-(void)TestCreate
{
  long key1 = [SampleApp_KeyGenerator generateId];
  long key2 = [SampleApp_KeyGenerator generateId];

  SampleApp_Customer *c = [[ SampleApp_Customer alloc] init]; 
  c.id_ = [SampleApp_LocalKeyGenerator generateId];
  c.fname = @"Dorothi"; 
  c.lname = @"Scranton";
  c.address = @"One Money Street";
  c.city = @"smallVille";
  c.state = @"MA";
  c.zip = @"97429";
  c.phone = @"2112222345";
  c.company_name = @"iAnywhere";
  c.surrogateKey = key1;
  SUPObjectList *orderlist = [ SampleApp_Sales_orderList getInstance];
  SampleApp_Sales_order *o1 = [[SampleApp_Sales_order alloc] init];
  o1.id_ = [SampleApp_LocalKeyGenerator generateId];
  o1.order_date = [NSDate date];
  o1.fin_code_id = @"r1";
  o1.region = @"Eastern";
  o1.sales_rep = 902;
  o1.surrogateKey = key2;
  [ o1 setCustomer:c];
  [orderlist add:o1];
  [c setSalesOrders:orderlist];
  [c save];
  [c refresh];
  [c submitPending];
  assert(c.pending == YES);
  [SampleAppDB synchronize];
}
Note: The values generated by LocalKeyGenerator do not support authentication with the Unwired Server, but only against a local data store on the device. LocalKeyGenerator is an appropriate method for use with a local business object. See Developer Guide: iOS Object API Applications > Reference > iOS Client Object API > Operations APIs > Local Business Object.

See the Sybase Unwired Platform online documentation for information on defining relationships that support cascading (composite) operations, and for specific multilevel insert requirements.