Modifying Your Personal Action Plan Can Impede Personal Fitness Goals

Whenever implementing data modifying logic using Query annotation (insert, update or delete) in JpaRepository, both @Transactional (not necessarily on the repository method) and @Modifying have to be used.

modifying your personal action plan can impede personal fitness goals 1

java - Why do I have to use @Modifying with @Transactional in spring ...

modifying your personal action plan can impede personal fitness goals 2

Second question first: the Modifying annotation lets you execute DML (inserts, updates, deletes) and DDL using JPA Query annotations where you put the DML or DDL where the query would normally go. To answer the first question, i would expect to use this in a service layer annotated with @Transactional instead of putting the annotation on the Repository, because these operations seem likely to ...

modifying your personal action plan can impede personal fitness goals 3

Yes you need @Transactional when modifying data even with @Modifying that is only an annotation to let Spring Data know you have a @Query that changes stuff. The @Transactional marks the start AND end of a transaction. If you put it in your service layer everything called from within a single method participates in the same transaction.

modifying your personal action plan can impede personal fitness goals 4

java - Do we need both @Transactional and @Modifying annotation in ...

modifying your personal action plan can impede personal fitness goals 5