While primary keys are used to identify and address a specific unique object, search keys are used to query for a list of objects. If you want to query for a list using primary key fields, these fields also require setting the <<SearchKey>> stereotype.
Only attributes of primitive types can be marked as primary or search key.
Figure: A Persistent State Class
Attributes having the stereotype PrimaryKey or SearchKey are represented with different icons in the containment tree of MagicDraw (see picture below).
Figure: Stereotyped Attributes of a Persistent State Class
Modifying Persistent State Classes
Be careful with modifying persistent state classes of a service already running on a Bridge. If you deploy the modified service, the service might refuse to start-up and throw an error:
Info: Loaded addon PState_AddOn successfully.
Fatal: Found persistent state objects of class "<name of the old class>" that does not exist in the repository anymore.
Fatal: Detected objects for which no metadata exist in the repository. Correct the problem either by restoring class definitions in the model or by deleting corresponding objects.
Fatal: Initializing service "PersistentStateService" failed
This can happen e.g. if you remove or change the name of the persistent state class but the persistent state database still contains objects of the old class. These objects become orphaned in this case.
You can fix this in two ways:
- Delete all old persistent state objects using the E2E Bridge (see Deleting Persistent State Objects).
- Redeploy the old service and let it work all persistent state objects before deploying the new one.