Complex Example

This example shows the usage of SUPCompositeTest, SUPSortCriteria, and SUPQuery to locate all customer objects based on particular criteria.

SUPQuery *props = [SUPQuery getInstance];
// Define the attribute based conditions.
// Users can pass in a string if they know the attribute name. R1 column name = attribute name.
SUPCompositeTest *innerCompTest = [SUPCompositeTest getInstance];
[innerCompTest setOperator:SUPCompositeTest_OR];
[innerCompTest add:[SUPAttributeTest equal:@"state":@"CA"]];
[innerCompTest add:[SUPAttributeTest equal:@"state":@"NY"]];
    
SUPCompositeTest *outerCompTest = [SUPCompositeTest getInstance];
[outerCompTest setOperator:SUPCompositeTest_OR];
[outerCompTest add:[SUPAttributeTest equal:@"fname":@"Jane"]];
[outerCompTest add:[SUPAttributeTest equal:@"lname":@"Doe"]];

[outerCompTest add:innerCompTest];
    
// Define the ordering:
SUPSortCriteria *sort = [SUPSortCriteria getInstance];
    
[sort add:[SUPAttributeSort ascending:@"fname"]];
[sort add:[SUPAttributeSort ascending:@"lname"]];

// Set the Query object:
props.testCriteria = (SUPTestCriteria*)outerCompTest;
props.sortCriteria = sort;
props.skip = 10;
props.take = 5;

SUPObjectList * customers2 = [SUP101Customer findWithQuery:props];
Note: "Order By" is not supported for a long varchar field.