Examples: Parameters and Cache Partitions

Create cache partitions based on mobile business object (MBO) and load argument definitions.

These examples use the employee table in the My Sample Database connection profile.

Create a mobile business object (MBO) that uses a load argument and personalization key to partition the Unwired Server cache database (CDB). The general process is:
  • In Unwired WorkSpace, create an MBO with a load argument from the employee table, add a personalization key, and map the load argument that defines how the CDB is partitioned to the personalization key.
  • Client (device application) partitions are created as new clients connect. Users set the personalization key in their application, and then synchronize and download data.
  • The CDB loads data that satisfies the MBO definition using the load argument value, which is the personalization key value in this example, passed by the client, and returns only those rows that matches the client's personalization key value.
For this example:
  1. Drag and drop the employee table, and edit the definition to include the state_param parameter (load argument):
    SELECT   emp_id,
      manager_id,
      emp_fname,
      emp_lname,
      dept_id,
      street,
      city,
      state,
      zip_code,
      phone,
      status,
      ss_number,
      salary,
      start_date,
      termination_date,
      birth_date,
      bene_health_ins,
      bene_life_ins,
      bene_day_care,
      sex FROM sampledb.dba.employee
    where state = :state_param
    
  2. Create a personalization key with these values:
    • Name – state_pk
    • Type – string(4)
    • All other entries – accept default values
  3. From the Attributes Load Arguments tab, map the load argument to the personalization key:
    • Argument – state_param
    • Datatype – string(4)
    • Nullable – no
    • Propagate to – state
    • Personalization key – state_pk
  4. Deploy the package to Unwired Server.
    Client and CDB behavior is:
    • Client 1 sets state_pk to "TX ", while client 2 uses "GA ". Two rows (one for each argument) are added to the parameter table in the CDB. Two trailing white spaces are added to pad the total length to four, since state_pk is defined as string(4).
    • The CDB partition table contains values that define the partition key for each partition (TX and GA).
    • The partition refresh table tracks the most recent refresh for each partition.

Only the data in the partition of interest refreshes. This is an important performance consideration for large tables.

Creating cache partitions based on compound parameter values

This example shows how to create a partitioned cache for the employee table where the partitions are defined by a compound partition key that uses two attributes: city and state.

Manually edit the SQL definition. For a query that does not require exact matches for the state or city parameters, use this MBO definition as the download query:
SELECT   emp_id,
  manager_id,
  emp_fname,
  emp_lname,
  dept_id,
  street,
  city,
  state,
FROM sampledb.dba.employee
WHERE state LIKE :state_param + '%'
AND city LIKE :city_param + '%'