ArticleRepository

@Repository
interface ArticleRepository : JpaRepository<Article, Long>

Functions

Link copied to clipboard
abstract fun count(): Long
abstract fun <S : Article> count(example: Example<S>): Long
Link copied to clipboard
abstract fun delete(entity: Article)
Link copied to clipboard
abstract fun deleteAll()
abstract fun deleteAll(entities: MutableIterable<Article>)
Link copied to clipboard
abstract fun deleteAllById(ids: MutableIterable<Long>)
Link copied to clipboard
Link copied to clipboard
abstract fun deleteAllInBatch()
abstract fun deleteAllInBatch(entities: MutableIterable<Article>)
Link copied to clipboard
abstract fun deleteById(id: Long)
Link copied to clipboard
Link copied to clipboard
abstract fun <S : Article> exists(example: Example<S>): Boolean
Link copied to clipboard
abstract fun existsById(id: Long): Boolean
Link copied to clipboard
abstract override fun <S : Article> findAll(example: Example<S>): MutableList<S>
abstract override fun <S : Article> findAll(example: Example<S>, sort: Sort): MutableList<S>
abstract override fun findAll(): MutableList<Article>
abstract override fun findAll(sort: Sort): MutableList<Article>
abstract fun findAll(pageable: Pageable): Page<Article>
abstract fun <S : Article> findAll(example: Example<S>, pageable: Pageable): Page<S>
Link copied to clipboard
abstract override fun findAllById(ids: MutableIterable<Long>): MutableList<Article>
Link copied to clipboard
abstract fun <S : Article, R : Any> findBy(example: Example<S>, queryFunction: Function<FluentQuery.FetchableFluentQuery<S>, R>): R
Link copied to clipboard
@Query(value = " SELECT a FROM Article a WHERE (:title IS NULL OR a.title LIKE CONCAT('%', :title, '%')) OR (:content IS NULL OR a.content LIKE CONCAT('%', :content, '%')) ")
abstract fun findByArticleTitleAndContent(@Param(value = "title") title: String? = null, @Param(value = "content") content: String? = null, pageable: Pageable): Page<Article>

게시글 제목으로 조회하는 메소드

Link copied to clipboard
abstract fun findByAuthorId(authorId: Long, pageable: Pageable): Page<Article>

작성자 ID로 게시글 조회 메소드

Link copied to clipboard
abstract fun findByCreatedAtBetween(createdAtStart: Instant, createdAtEnd: Instant): List<Article>

게시글 생성일자 범위로 조회하는 메소드

Link copied to clipboard
abstract fun findById(id: Long): Optional<Article>
Link copied to clipboard
abstract fun <S : Article> findOne(example: Example<S>): Optional<S>
Link copied to clipboard
abstract fun flush()
Link copied to clipboard
abstract fun getById(id: Long): Article
Link copied to clipboard
abstract fun getOne(id: Long): Article
Link copied to clipboard
abstract fun getReferenceById(id: Long): Article
Link copied to clipboard
@Modifying
@Query(value = " update Article a set a.viewCount = a.viewCount + 1 where a.id = :id")
abstract fun increaseViewCount(id: Long): Int

조회수 증가 메소드

Link copied to clipboard
abstract fun <S : Article> save(entity: S): S
Link copied to clipboard
abstract override fun <S : Article> saveAll(entities: MutableIterable<S>): MutableList<S>
Link copied to clipboard
abstract fun <S : Article> saveAllAndFlush(entities: MutableIterable<S>): MutableList<S>
Link copied to clipboard
abstract fun <S : Article> saveAndFlush(entity: S): S