An object query is automatically generated for each mobile business object (MBO) attribute identified as a Primary key, as well as an additional "composite" object query if there are multiple primary keys.
Object queries generated from primary key attributes
return a single instance (row) of data, which is useful in many applications. For example, you could create a new record and use the object query to return that record to the device application. Depending on the data source to which the MBO is bound, it may require multiple primary keys to uniquely identify an instance of the data. Unwired WorkSpace:
- Generates an object query named findByPrimaryKey. This query could be generated from a single primary key attribute, or a composite, if multiple attributes are identified as primary keys:
- Generates an object query named findByPrimaryKey if there is only one primary key attribute.
- If there are multiple primary keys, generates an object query for every attribute identified as a primary key . For example, primary keys attA, attB, and attC generates queries findByattA, findByattB, findByattC, and findByPrimaryKey (which is a composite of the three primary keys).
- For auto-generated queries, the return type for 'findByPrimaryKey is a single object, with a setting of isMany = false, for other auto-generated queries, the return type is a multiple object, with a setting of isMany = true.
- Allows you to delete any of the auto-generated object queries. A warning message appears, if you delete the findByPrimaryKey object query. Deleting other queries does not generate a warning message. For example, if you:
- Remove query findByA, uncheck Primary key for attribute A, then
check Primary key for attribute A again, the query findByA is generated again.
- Remove query findByPrimaryKey, then check or uncheck Primary key for any attribute, findByPrimaryKey is generated again.
The steps for manually generating the findByPrimaryKey object query are: