Onyx Database: Deleting an Entity Tutorial

You can download the code for this example here: OnyxDevTools/onyx-database-samples/persisting-data.

Much like persisting an entity, deleting is a core feature of the Onyx Database ORM. This tutorial will guide you through deleting a single entity and verifying that it was deleted.

  1. Get an instance of an Entity Persistence Manager via the Persistence Manager Factory
  2. Persist an entity, you will use it later to delete.
    Persisting an entity tutorial can be found here: Saving An Entity
  3. Invoke the PersistenceManager#deleteEntity method.
  4. Attempt to find the deleted entity.
    When using the PersistenceManager#find, if the entity you are trying to retrieve was deleted, the manager will throws a NoResultsFoundException. A NoResultsFoundException is a typical response when attempting to find, hydrate, or delete an instantiated Managed Entity that does not exist
  5. Batch Deleting