The Object API supports one-to-one, one-to-many, and many-to-one relationships.
Navigate between MBOs using relationships.
SampleAppCustomer *customer = [SampleAppCustomer find:101]; SUPObjectList *orders = customer.salesOrders;
SUPQuery *query = [SUPQuery getInstance]; [query select:@"c.fname,c.lname,s.order_date,s.region"]; [query from:@"Customer":@"c"]; [query join:@"SalesOrder":@"s":@"s.cust_id":@"c.id"]; query.testCriteria = [SUPAttributeTest match:@"c.lname":@"Devlin"]; SUPQueryResultSet* resultSet = [SUP101SUP101DB executeQuery:query];
If the primary key for a parent is assigned by the EIS, you can use a multilevel insert cascade operation to create the parent and child objects in a single operation without synchronizing multiple times. The returned primary key for the parent's create operation populates the children prior to their own creation.
The following example illustrates how to submit the parent MBO which also submits the child's operation:
SampleAppCustomer *customer = [ SampleAppCustomer find: 32] customer.city = @"Dublin"; SampleAppSales_order* order = [SampleAppSales_order find: 1220]; order.region = @"SA"; //update any field [order update]; //call update on the child record [order refresh]; [order.customer submitPending];