How can you create a custom query method in a Spring Data JPA repository?

  • By defining a method in the repository interface with a name that follows specific conventions.
  • By using the @Query annotation to specify the JPQL query.
  • By extending the JpaRepository interface and inheriting built-in methods.
  • By using the @CustomQuery annotation to define the custom query.
In Spring Data JPA, custom query methods are created by defining a method in the repository interface with a name that follows specific conventions. Spring Data JPA analyzes the method name and generates the appropriate SQL query, making it a powerful and convenient way to create custom queries without writing SQL explicitly. The other options, while valid in certain contexts, do not describe the typical way to create custom query methods in Spring Data JPA.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *