Class HibernateRatingDAO

    • Constructor Detail

      • HibernateRatingDAO

        public HibernateRatingDAO()
    • Method Detail

      • store

        public boolean store​(Rating rating,
                             DocumentHistory transaction)
                      throws PersistenceException
        Description copied from interface: RatingDAO
        Stores a rating and saves the document's history
        Specified by:
        store in interface RatingDAO
        Parameters:
        rating - the rating
        transaction - session informations
        Returns:
        true id the rating has been correctly stored
        Throws:
        PersistenceException - raised in case of database errors
      • findVotesByDocId

        public Rating findVotesByDocId​(long docId)
        Description copied from interface: RatingDAO
        Returns a rating that contains count and average of vote on the given document
        Specified by:
        findVotesByDocId in interface RatingDAO
        Parameters:
        docId - ID of the document
        Returns:
        the rating for the document
      • findByDocIdAndUserId

        public Rating findByDocIdAndUserId​(long docId,
                                           long userId)
        Description copied from interface: RatingDAO
        Finds the rating for the given user id and the given document id
        Specified by:
        findByDocIdAndUserId in interface RatingDAO
        Parameters:
        docId - ID of the document
        userId - ID of the user
        Returns:
        the vote of the given user on the document
      • findByDocId

        public List<Rating> findByDocId​(long docId)
        Description copied from interface: RatingDAO
        Finds the ratings stored for the given document id
        Specified by:
        findByDocId in interface RatingDAO
        Parameters:
        docId - ID of the document
        Returns:
        the list of ratings