In what scenario would you use the @Modifying annotation in a Spring Data JPA repository method?
- When creating a new JPA entity object.
- When defining a custom query for a read operation.
- When performing a write operation that modifies the database (e.g., INSERT, UPDATE, DELETE).
- When retrieving data from multiple tables using a JOIN operation.
The @Modifying annotation in a Spring Data JPA repository method is used when performing a write operation that modifies the database, such as INSERT, UPDATE, or DELETE. It indicates to Spring that the method is going to modify the data, so it should be included in a transaction. The other options are not scenarios where @Modifying is typically used.
Loading...
Related Quiz
- What is the role of the @WebMvcTest annotation in Spring Boot testing?
- How can you optimize the performance of Spring Data JPA repositories when dealing with large datasets?
- What are the security considerations when validating a JWT token in a Spring Boot application?
- What is the significance of the @Transactional annotation in Spring Data JPA?
- How can you configure profiles in Spring Boot to optimize configuration loading during testing?