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.
Add your answer
Loading...

Leave a comment

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