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

  • By adding a method to the repository interface with a name following Spring's naming conventions.
  • By creating a SQL query and embedding it in the repository method using @Query annotation.
  • By extending the JpaRepository and using its built-in query methods.
  • By defining a custom method in the service layer of the application.
In Spring Data JPA, you can create a custom query method by simply adding a method to the repository interface with a name following Spring's naming conventions. Spring Data JPA will automatically generate the query based on the method name, allowing you to perform database operations without writing explicit SQL queries. The other options either involve using native SQL queries or do not adhere to the Spring Data JPA conventions for creating custom queries.
Add your answer
Loading...

Leave a comment

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