Interface CommentRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<CommentEntity,Long>, org.springframework.data.jpa.repository.JpaRepository<CommentEntity,Long>, org.springframework.data.repository.ListCrudRepository<CommentEntity,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<CommentEntity,Long>, org.springframework.data.repository.PagingAndSortingRepository<CommentEntity,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<CommentEntity>, org.springframework.data.repository.Repository<CommentEntity,Long>

public interface CommentRepository extends org.springframework.data.jpa.repository.JpaRepository<CommentEntity,Long>
JPA repository for managing comment persistence operations.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    existsByIdAndAuthorId(Long commentId, Long authorId)
    Checks if a comment exists with the specified ID and author ID.
    Retrieves all comments associated with a specific post.
    findById(Long commentId)
     

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findAllByPostId

      List<CommentEntity> findAllByPostId(Long postId)
      Retrieves all comments associated with a specific post.
      Parameters:
      postId - the ID of the post
      Returns:
      list of comments for the post
    • existsByIdAndAuthorId

      boolean existsByIdAndAuthorId(Long commentId, Long authorId)
      Checks if a comment exists with the specified ID and author ID.
      Parameters:
      commentId - the ID of the comment
      authorId - the ID of the author
      Returns:
      true if a comment with the given ID and author exists, false otherwise
    • findById

      Optional<CommentEntity> findById(Long commentId)
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<CommentEntity,Long>