Interface EntityManager

All Known Implementing Classes:
PojoEntityManager, TemplateEntityManager

public interface EntityManager
Provides access to entities. Each type has its own entity manager, also, the manager is bound to the context. Thus get it from the persist context.
  • Method Details

    • get

      Get an entity by a known primary key. If the entity with the specified key isn't present, in the database, this method throws a NotFoundException. Use retrieve(PrimaryKey), if you prefer a `null` value, if the entity does not exist.
      Parameters:
      key - The primary key.
      Returns:
      An entity facade for the entity with the specified key
      Throws:
      NotFoundException - If the entity with the specified primary key doesn't exists.
      See Also:
    • retrieve

      @Nullable @Nullable Entity retrieve(PrimaryKey key)
      Retrieve an entity by a known primary key. Unlike get(PrimaryKey), this method returns null if the entity does not exist in the database or the current user has no access to the entity.
      Parameters:
      key - The PrimaryKey of the entity.
      Returns:
      The entity or null, if the entity does not exist or is not accessible.
      Throws:
      PersistException - If an error occurs.
      See Also:
    • get

      Entity get(String uniqueId)
      Get an entity by unique_id field. Throws if entity cannot be found.
      Parameters:
      uniqueId - unique id value of entity.
      Returns:
      An entity facade for the entity with the specified unique_id
      See Also:
    • retrieve

      @Nullable @Nullable Entity retrieve(String uniqueId)
      Retrieve an entity by unique_id field.
      Parameters:
      uniqueId - unique id value of entity.
      Returns:
      The entity or null, if the entity does not exist or is not accessible.
      See Also:
    • createQueryForAll

      Query createQueryForAll()
      Create a Query for all entities of that type.
      Returns:
      A query that queries all entities.
    • createQuery

      Query createQuery(Collection<PrimaryKey> keys)
      Create a query that returns objects with known primary keys. Note that the results will be returned in random order unless a sorting is applied. They will not be returned in the given keys order. Use EntityLists.orderedList(EntityList, PrimaryKey[]).
      Parameters:
      keys - A collection of known primary keys.
      Returns:
      The executable query.
    • createEntityList

      EntityList createEntityList(Entity... entities)
      Creates an EntityList of persistent entities of the same EntityModel.
      Parameters:
      entities - Must be of same EntityModel, and persistent (not conception).
      Returns:
      new EntityList of given persistent entities.
      Throws:
      IllegalArgumentException - if one entity is of another EntityModel than the first, or if not at least one entity is passed, or if one is not persistent (has no key).
    • createEntityList

      EntityList createEntityList(PrimaryKey... entities)
    • create

      Entity create()
      Create a new entity (state Entity.State.CONCEPTION. The entity won't have any primary key yet and will be written into the storage when the transaction is committed.
      Returns:
      The newly created entity.
    • delete

      List<Entity> delete(Condition condition)
      Deletes all entities of the current EntityModel on which the condition applies to in a single sql statement. Does not provide cascading delete.
    • getModel

      EntityModel getModel()
      Get the entity type's model.
      Returns:
      The entity type's model.
    • getContext

      Context getContext()
      Get the persistence context of this entity manager.
      Returns:
      The persistence context of this entity manager.
    • addEntityListener

      void addEntityListener(EntityListener l)
      Parameters:
      l - The EntityListener to be added.
    • removeEntityListener

      void removeEntityListener(EntityListener l)
      Remove an EntityListener.
      Parameters:
      l - The EntityListener to be removed.
    • addEntityFacadeListener

      void addEntityFacadeListener(EntityFacadeListener l)
      Parameters:
      l - The EntityFacadeListener to be added.
    • removeEntityFacadeListener

      void removeEntityFacadeListener(EntityFacadeListener l)
      Parameters:
      l - The EntityFacadeListener to be removed.