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

Consider creating a Customer and a new SalesOrder at the same time on the client side, where the SalesOrder has a reference to the new Customer identifier. The following example demonstrates a multilevel insert:

Customer customer = new Customer();
customer.Fname = “firstName”;
customer.Lname = “lastName”;
customer.Phone = “777-8888”;
customer.Save();
SalesOrder order = new SalesOrder();
order.Customer = customer;
order.Order_date = DateTime.Now;
order.Region = "Eastern";
order.Sales_rep = 102;
customer.Orders.Add(order);
//Only the parent MBO needs to call Save()
customer.Save();
//Must submit parent
customer.SubmitPending();

To insert an order for an existing customer, first find the customer, then create a sales order with the customer ID retrieved:

Customer customer = Customer.FindByPrimaryKey(102);
SalesOrder order = new SalesOrder();
order.Customer = customer;
order.Order_date = DateTime.UtcNow;
order.Region = "Eastern";
order.Sales_rep = 102;
customer.Orders.Add(order);
order.Save();
customer.SubmitPending();

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