Interface BaseDao<T>

    • Method Detail

      • getElementClass

        Class<? extends T> getElementClass()
        Obtain the element class of BaseDao.
      • getIdentifierPropertyName

        String getIdentifierPropertyName()
        Obtain the identifiable property name for BaseDao.
      • create

        @CheckReturnValue
        Collection<T> create​(Collection<T> entities)
        Crates all the given entities in the persistent storage.
        Parameters:
        entities - the entities to be crated.
        Returns:
        collection of entities representing the instances in the persistent storage that were created.
      • create

        @CheckReturnValue
        T create​(T entity)
        Create an object. If the entity type is immutable, this may also remove any existing entities identified by an appropriate 'find' method.
        Parameters:
        entity - the entity to create
        Returns:
        the persistent version of the entity
      • load

        Collection<T> load​(Collection<Long> ids)
        Loads entities with given ids form the persistent storage.
        Parameters:
        ids - the IDs of entities to be loaded. If some IDs are not found or null, they are skipped.
        Returns:
        collection of entities with given ids.
      • load

        @Nullable
        T load​(Long id)
        Loads the entity with given id from the persistent storage.
        Parameters:
        id - the id of entity to load.
        Returns:
        the entity with given ID, or null if such entity does not exist or if the passed ID was null
        See Also:
        Session.get(Class, Serializable)
      • loadAll

        Collection<T> loadAll()
        Loads all instanced of specific class from the persistent storage.
        Returns:
        a collection containing all instances that are currently accessible.
      • loadReference

        Collection<T> loadReference​(Collection<Long> ids)
        Load references for all the given IDs.

        Entities already in the session will be returned directly.

      • loadReference

        @Nonnull
        T loadReference​(Long id)
        Load reference for an entity.

        If the entity is already in the session, it will be returned instead. Note that unlike load(Long), this method will not return null if the entity does not exist.

        You may freely access the Identifiable.getId() field without triggering proxy initialization.

        See Also:
        Session.load(Object, Serializable)
      • countAll

        long countAll()
        Counts all instances of specific class in the persitent storage.
        Returns:
        number that is the amount of instances currently accessible.
      • remove

        void remove​(Long id)
        Remove a persistent instance based on its ID. The implementer is trusted to know what type of object to remove. Note that this method is to be avoided for Securable, because it will leave cruft in the ACL tables. We may fix this by having this method return the removed object.
        Parameters:
        id - the ID of the entity to be removed
      • remove

        void remove​(T entity)
        Remove a persistent instance
        Parameters:
        entity - the entity to be removed
      • update

        void update​(Collection<T> entities)
        Parameters:
        entities - Update the entities. Not supported if the entities are immutable.
      • update

        void update​(T entity)
        Parameters:
        entity - Update the entity. Not supported if the entity is immutable.
      • find

        @Nullable
        @CheckReturnValue
        T find​(T entity)
        Does a look up for the given entity in the persistent storage, usually looking for a specific identifier ( either id or a string property).
        Parameters:
        entity - the entity to look for.
        Returns:
        an entity that was found in the persistent storage, or null if no such entity was found.
      • findOrCreate

        @CheckReturnValue
        T findOrCreate​(T entity)
        Calls the find method, and if this method returns null, creates a new instance in the persistent storage.
        Parameters:
        entity - the entity to look for and persist if not found.
        Returns:
        the given entity, guaranteed to be representing an entity present in the persistent storage.