Find entity by ID within a Partition

Similar to the previous tutorial, a partition is used to access distributed data among different partitions.

You can download the code for this example here:

OnyxDevTools/onyx-database-samples/partition.

  1. Create a PhoneNumber and CallLog entity.

    For this example we have a Phone that makes calls and logs the metadata regarding the call. We would like to make the storage of these call logs more robust so we can run some analytical queries to determine what calls were monitored by the NSA for each zip code.

    Notes:
    Make an entity partitioned by adding the @Partition annotation to the attribute that is used to differentiate the partition.
    Each entity maintains its own partition. Entire object graphs are not stored in a partition.
    If the partition attribute value is null, the data will be stored in a default partition.
  2. Populate test data in different partitions.

    Call logs are stored in partitions for area codes 555 and 123.

    Notes:
    Each partition is stored in a separate physical storage.
    An entities primary key or identifier is not unique among different partitions. In other words, you can have the same identifier for entities in different partitions.
    The partition should be pre-determined. What me mean by that is the partition cannot be defined by runtime listeners. It must be defined prior to persisting the entity(s).
  3. Find a CallLog by ID in partition 555.

    Notice that partition 555 has a record with callLogId = 1 and partition 123 has a record with callLogId = 1. Onyx uses the primary key of an entity as contrived key of their partition and identifier value.

    Notes:
    Make sure the CallLog entities are different in each partition.
  4. Lifecycle Events