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.
Loading...
Related Quiz
- In Spring Boot's project structure, where should the application properties file be placed?
- In Mockito, to ensure that a mocked method was called with specific arguments, you would use the _____ method.
- To authorize access to method-level security in Spring Security, the _______ annotation can be used.
- integrate a custom authentication provider in Spring Security for implementing a custom authentication mechanism?
- You are tasked to implement dynamic role-based access control in a Spring Security application where roles and permissions can be modified at runtime. What approach and components of Spring Security would you use to fulfill this requirement?