nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #37

Which two are required to use transactions in Spring? (Choose two.)

The correct answer is A. Add @EnableTransactionManagement to a Java configuration class. B. Annotate a class, an interface, or individual methods requiring a transaction with the. Enabling transactions in Spring requires two things working together: A activates the Spring transaction infrastructure by telling Spring to look for @Transactional annotations and proxy the appropriate beans, while B marks which classes, interfaces, or methods should actually…

Core Spring

Question

Which two are required to use transactions in Spring? (Choose two.)

Options

  • AAdd @EnableTransactionManagement to a Java configuration class.
  • BAnnotate a class, an interface, or individual methods requiring a transaction with the
  • CA class must be annotated with @Service and @Transaction.
  • DA class requiring a transaction must implement the TransactionInterceptor interface.
  • EWrite a Spring AOP advice to implement transactional behavior.

How the community answered

(46 responses)
  • A
    91% (42)
  • C
    4% (2)
  • D
    2% (1)
  • E
    2% (1)

Explanation

Enabling transactions in Spring requires two things working together: A activates the Spring transaction infrastructure by telling Spring to look for @Transactional annotations and proxy the appropriate beans, while B marks which classes, interfaces, or methods should actually be wrapped in a transaction - without both, either the infrastructure isn't running or nothing is targeted.

Why the distractors are wrong:

  • C is wrong because @Service is unrelated to transactions; @Transactional alone (not @Transaction) is what marks transactional behavior, and it doesn't require @Service.
  • D is wrong because TransactionInterceptor is an internal Spring mechanism you never implement directly - Spring does that for you via AOP under the hood.
  • E is wrong because writing your own AOP advice is the old, manual way; @EnableTransactionManagement + @Transactional replaces that entirely with declarative transaction management.

Memory tip: Think of it as a two-key ignition - @EnableTransactionManagement is the engine (turns on the transaction system), and @Transactional is the key (tells Spring which code to actually protect with a transaction). You need both keys to start the car.

Topics

#Transaction Management#Spring Configuration#@EnableTransactionManagement#@Transactional

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice