-1

@Transactional annotation is based on AOP concept.

When you annotate a method with @Transactional, Spring dynamically creates a proxy that implements the same interface(s) as the class you are annotating. And when clients make calls into your object, the calls are intercepted and the behaviors gets injected via the proxy mechanism.

@Transactional annotation works similar to transactions in EJB.

  • Does this answer your question? [Spring - @Transactional - What happens in background?](https://stackoverflow.com/questions/1099025/spring-transactional-what-happens-in-background) – Nathan Hughes Jan 05 '22 at 15:06

1 Answers1

0

The @Transactional annotation that specifies the semantics of the transactions on a method.

  • According to hibernate documentation Database, or system, transaction boundaries are always necessary for update and delete operation on database.

      Subscription findBySubredditIdAndUserId(Long subredditId, Long userId);
    
      List<Subscription> findBySubredditIdInAndUserId(List<Long> subredditId, Long userId);
    
      @Transactional
      @Modifying
      @Query("DELETE FROM Subscription sub WHERE sub.subredditId = ?1 and sub.userId = ?2")
      void deleteSubscription(Long subRedditId, Long userId);
    
    
    }