Interface PersistenceManager<T>

  • Type Parameters:
    T - type of the object the DAO works with.

    public interface PersistenceManager<T>
    Generic interface with basic DAO methods for objects of type <T>.
    Author:
    n.milutinovic
    • Method Detail

      • find

        T find​(WmId id,
               PersistenceContext context)
        Find one instance, with the given ID.
        Parameters:
        id - ID to use for lookup.
        context - persistence context.
        Returns:
        instance found or null.
      • create

        T create​(T entity,
                 PersistenceContext context)
        Persist the given instance to the repository and return the persisted version.
        Parameters:
        entity - entity to be created in persistent storage.
        context - persistence context holding session.
        Returns:
        persisted instance.
      • copy

        <T> T copy​(T entity,
                   PersistenceContext persistenceContext)
        Copies an entity and the entire tree of its children. This method traverses all @Child relations.
        Parameters:
        entity - entity to be copied in persistent storage.
        context - persistence context holding session.
        Returns:
        copied instance.
      • delete

        void delete​(T entity,
                    PersistenceContext context)
             throws DomainException
        Delete entity from the persistent storage.
        Parameters:
        entity - entity to be deleted.
        context - persistence context.
        Throws:
        DomainException - if the entity does not exist.
      • save

        void save​(T entity,
                  PersistenceContext context)
           throws DomainException
        Save/update persisted entity.
        Parameters:
        entity - entity to be saved.
        context - persistence context.
        Throws:
        DomainException - in case of entity not being properly set or repository problems.
      • getAll

        Set<T> getAll​(PersistenceContext context)
        Get all entities served by the given PM and stored under it's node.
        Parameters:
        context - persistence context.
        Returns:
        a collection of all entities of implied type.
      • removeProperty

        void removeProperty​(T entity,
                            String property,
                            PersistenceContext context)
                     throws DomainException
        Remove the property from the persistent image of the given entity.
        Parameters:
        entity - entity for property removal.
        property - name of the property to remove.
        context - persistence context for this operation.
        Throws:
        DomainException - in case entity has no persistent image.