content: package com.bookstore.repository;
  
  import com.bookstore.entity.Author;
  
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.data.jpa.repository.Modifying;
  import org.springframework.data.jpa.repository.Query;
  import org.springframework.data.jpa.repository.QueryHints;
  import org.springframework.stereotype.Repository;
  import org.springframework.transaction.annotation.Transactional;
  
  import javax.persistence.QueryHint;
  import java.util.List;
  
  import static org.hibernate.jpa.QueryHints.HINT_PASS_DISTINCT_THROUGH;
  
  @Repository
  @Transactional(readOnly = true)
  public interface AuthorRepository extends JpaRepository<Author, Long> {
      @QueryHints(value = @QueryHint(name = HINT_PASS_DISTINCT_THROUGH, value = "false"))
      @Query("SELECT DISTINCT a FROM Author a JOIN FETCH a.books b WHERE a.age > ?1")
      List<Author> findGtGivenAge(int age);
  
      @Transactional
      @Modifying(flushAutomatically = true, clearAutomatically = true)
      @Query(value = "UPDATE Author a SET a.age = a.age + 1, a.version = a.version + 1")
      int updateInBulk();
  
      @Transactional
      @Modifying(flushAutomatically = true, clearAutomatically = true)
      @Query(value = "UPDATE Author a SET a.age = a.age + 1, a.version = a.version + 1 " +
              "WHERE a IN ?1")
      int updateInBulk(List<Author> authors);
  }