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.
Loading...
Related Quiz
- How can you handle validation errors and display them to the user in Spring Boot?
- How can you customize the response message sent to the client when a validation error occurs?
- The _____ in a YAML configuration file in Spring Boot is used to represent a list of values.
- In a Spring Boot application, the _____ annotation can be used to enable OAuth2 Authorization Server features.
- How can you configure a custom method security expression handler in Spring Security?