Interface BambooObjectDao<T extends BambooObject>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <E extends T>
      long
      countAll​(@NotNull Class<E> aClass)
      Finds the count of all entities that implement the given Class
      <E extends T>
      long
      countWithRestriction​(@NotNull Class<E> aClass, org.hibernate.criterion.Criterion restriction)
      Finds the count of all entities that implement the given class and satisfy the provided restriction
      void delete​(T t)
      Removes the given entity from the database
      <E extends T>
      void
      deleteAll​(@NotNull Collection<E> entities)
      Remove all elements in the collection from database
      <E extends T>
      @NotNull Collection<E>
      findAll​(@NotNull Class<E> aClass)
      Finds all the entities that implement the given Class
      <E extends T>
      E
      findById​(long id, @NotNull Class<E> aClass)
      Find an entity by its id
      T merge​(T unmanagedEntity, @NotNull Class<? extends T> entityClass)
      Merges the state of the given unmanaged entity.
      void save​(T t)
      Saves the given entity.
      <E extends T>
      void
      saveAll​(@NotNull Collection<E> entities)
      Save all entities in the collection to the database
    • Method Detail

      • save

        void save​(@NotNull
                  T t)
        Saves the given entity. If the entity implementation is an instance of EntityObject this method will: - update EntityObject.getLastModificationDate() - set EntityObject.getCreationDate() if the object has not been saved
        Parameters:
        t - entity to be saved
      • saveAll

        <E extends T> void saveAll​(@NotNull
                                   @NotNull Collection<E> entities)
        Save all entities in the collection to the database
        Parameters:
        entities - entities to be saved to database
      • merge

        @NotNull
        T merge​(@NotNull
                T unmanagedEntity,
                @NotNull
                @NotNull Class<? extends T> entityClass)
        Merges the state of the given unmanaged entity.

        This method should only be used with entities which are not currently managed by Hibernate, otherwise save(BambooObject) should be called.

        If the entity implementation is an interface of EntityObject, the EntityObject.getCreationDate() and EntityObject.getLastModificationDate() properties will be updated accordingly (the former only if a new database object is created).

        Parameters:
        unmanagedEntity - entity not managed by Hibernate to merge
        entityClass - class of the entity
        Returns:
        managed entity as a result of merging and persisting the data - may be either a newly created or updated database object
      • delete

        void delete​(@NotNull
                    T t)
        Removes the given entity from the database
        Parameters:
        t - entity to be removed
      • deleteAll

        <E extends T> void deleteAll​(@NotNull
                                     @NotNull Collection<E> entities)
        Remove all elements in the collection from database
        Parameters:
        entities - elements to be removed from database
      • findAll

        @NotNull
        <E extends T> @NotNull Collection<E> findAll​(@NotNull
                                                     @NotNull Class<E> aClass)
        Finds all the entities that implement the given Class
        Parameters:
        aClass - class of entity
        Returns:
        entities
      • countAll

        <E extends T> long countAll​(@NotNull
                                    @NotNull Class<E> aClass)
        Finds the count of all entities that implement the given Class
      • countWithRestriction

        <E extends T> long countWithRestriction​(@NotNull
                                                @NotNull Class<E> aClass,
                                                org.hibernate.criterion.Criterion restriction)
        Finds the count of all entities that implement the given class and satisfy the provided restriction
      • findById

        @Nullable
        <E extends T> E findById​(long id,
                                 @NotNull
                                 @NotNull Class<E> aClass)
        Find an entity by its id
        Parameters:
        id - id of entity
        aClass - class of entity
        Returns:
        entity